{"action":"created","issue":{"url":"https://api.github.com/repos/cargomedia/CM/issues/1812","labels_url":"https://api.github.com/repos/cargomedia/CM/issues/1812/labels{/name}","comments_url":"https://api.github.com/repos/cargomedia/CM/issues/1812/comments","events_url":"https://api.github.com/repos/cargomedia/CM/issues/1812/events","html_url":"https://github.com/cargomedia/CM/issues/1812","id":90613131,"number":1812,"title":"Layout::loadPage: Error catching too broad?","user":{"login":"njam","id":360800,"avatar_url":"https://avatars.githubusercontent.com/u/360800?v=3","gravatar_id":"","url":"https://api.github.com/users/njam","html_url":"https://github.com/njam","followers_url":"https://api.github.com/users/njam/followers","following_url":"https://api.github.com/users/njam/following{/other_user}","gists_url":"https://api.github.com/users/njam/gists{/gist_id}","starred_url":"https://api.github.com/users/njam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/njam/subscriptions","organizations_url":"https://api.github.com/users/njam/orgs","repos_url":"https://api.github.com/users/njam/repos","events_url":"https://api.github.com/users/njam/events{/privacy}","received_events_url":"https://api.github.com/users/njam/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"vogdb","id":372386,"avatar_url":"https://avatars.githubusercontent.com/u/372386?v=3","gravatar_id":"","url":"https://api.github.com/users/vogdb","html_url":"https://github.com/vogdb","followers_url":"https://api.github.com/users/vogdb/followers","following_url":"https://api.github.com/users/vogdb/following{/other_user}","gists_url":"https://api.github.com/users/vogdb/gists{/gist_id}","starred_url":"https://api.github.com/users/vogdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vogdb/subscriptions","organizations_url":"https://api.github.com/users/vogdb/orgs","repos_url":"https://api.github.com/users/vogdb/repos","events_url":"https://api.github.com/users/vogdb/events{/privacy}","received_events_url":"https://api.github.com/users/vogdb/received_events","type":"User","site_admin":false},"milestone":null,"comments":0,"created_at":"2015-06-24T08:45:32Z","updated_at":"2015-06-24T12:20:46Z","closed_at":null,"body":"The ajax request in `loadPage()` previously would handle *ajax* error in an error callback:\r\n```js\r\n    this._pageRequest = this.ajaxModal('loadPage', {path: path}, {\r\n      success: function(response) {\r\n[...]\r\n      },\r\n      error: function(msg, type, isPublic) {\r\n[...]\r\n      }\r\n    });\r\n```\r\nIf anything went wrong in the `success` handler it would throw an unhandled error and would eventually be logged back to our server as a \"JS error\".\r\n\r\nWith the new Promise-based implementation the code looks like this:\r\n```js\r\n    this._pageRequest = this.ajaxModal('loadPage', {path: path})\r\n      .then(function(response) {\r\n[...]\r\n      })\r\n      .catch(function(error) {\r\n[...]\r\n      })\r\n```\r\nWhich means that an error in `then` will be catched in `catch` and *not* be logged to the server.\r\n\r\nI guess it's good to set the layout into an \"error\" state in case of *any* errors. Should we additionally throw again to log it to the server?\r\n@vogdb @tomaszdurka wdyt?\r\ncc @fauvel "},"comment":{"url":"https://api.github.com/repos/cargomedia/CM/issues/comments/114848753","html_url":"https://github.com/cargomedia/CM/issues/1812#issuecomment-114848753","issue_url":"https://api.github.com/repos/cargomedia/CM/issues/1812","id":114848753,"user":{"login":"vogdb","id":372386,"avatar_url":"https://avatars.githubusercontent.com/u/372386?v=3","gravatar_id":"","url":"https://api.github.com/users/vogdb","html_url":"https://github.com/vogdb","followers_url":"https://api.github.com/users/vogdb/followers","following_url":"https://api.github.com/users/vogdb/following{/other_user}","gists_url":"https://api.github.com/users/vogdb/gists{/gist_id}","starred_url":"https://api.github.com/users/vogdb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vogdb/subscriptions","organizations_url":"https://api.github.com/users/vogdb/orgs","repos_url":"https://api.github.com/users/vogdb/repos","events_url":"https://api.github.com/users/vogdb/events{/privacy}","received_events_url":"https://api.github.com/users/vogdb/received_events","type":"User","site_admin":false},"created_at":"2015-06-24T12:20:46Z","updated_at":"2015-06-24T12:20:46Z","body":"ok, we can do it but that would require also to throw the error in\r\n```js\r\n      $(window).on('unhandledrejection', function(e) {\r\n        e.preventDefault();\r\n        var error = e.originalEvent.detail.reason;\r\n        if (!(error instanceof Promise.CancellationError)) {\r\n          cm.error.trigger(error.msg, error.type, error.isPublic);\r\n        }\r\n      });\r\n```\r\nbecause now all the uncaught errors is handled there.\r\n\r\n@njam is it ok ?"}}