{"action":"opened","issue":{"url":"https://api.github.com/repos/angular/zone.js/issues/46","labels_url":"https://api.github.com/repos/angular/zone.js/issues/46/labels{/name}","comments_url":"https://api.github.com/repos/angular/zone.js/issues/46/comments","events_url":"https://api.github.com/repos/angular/zone.js/issues/46/events","html_url":"https://github.com/angular/zone.js/issues/46","id":58314668,"number":46,"title":"Zone is eating exceptions","user":{"login":"mhevery","id":111951,"avatar_url":"https://avatars.githubusercontent.com/u/111951?v=3","gravatar_id":"","url":"https://api.github.com/users/mhevery","html_url":"https://github.com/mhevery","followers_url":"https://api.github.com/users/mhevery/followers","following_url":"https://api.github.com/users/mhevery/following{/other_user}","gists_url":"https://api.github.com/users/mhevery/gists{/gist_id}","starred_url":"https://api.github.com/users/mhevery/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mhevery/subscriptions","organizations_url":"https://api.github.com/users/mhevery/orgs","repos_url":"https://api.github.com/users/mhevery/repos","events_url":"https://api.github.com/users/mhevery/events{/privacy}","received_events_url":"https://api.github.com/users/mhevery/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-02-20T06:21:53Z","updated_at":"2015-02-20T06:21:53Z","closed_at":null,"body":"If library throws a non `Error` exception then `Zone` eats the exception in console. See: [Chrome bug 460386](https://code.google.com/p/chromium/issues/detail?id=460386)\r\n\r\nThe issue is in [`zone.js`](https://github.com/angular/zone.js/blob/11c025bcacfd1753a3e872eb5f75786d40242a12/zone.js#L91)\r\n\r\nThis code:\r\n```\r\n    try {\r\n      this.beforeTask();\r\n      result = fn.apply(applyTo, applyWith);\r\n    } catch (e) {\r\n      if (zone.onError) {\r\n        zone.onError(e);\r\n      } else {\r\n        throw e;\r\n      }\r\n    } finally {\r\n      this.afterTask();\r\n      window.zone = oldZone;\r\n    }\r\n\r\n```\r\n\r\nshould be rewritten as:\r\n```\r\n try {\r\n    if (zone.onError) {\r\n      try {\r\n        this.beforeTask();\r\n        result = fn.apply(applyTo, applyWith);\r\n      } catch (e) {\r\n          zone.onError(e);\r\n      }\r\n    } else {\r\n      this.beforeTask();\r\n      result = fn.apply(applyTo, applyWith);\r\n    }\r\n  } finally {\r\n    this.afterTask();\r\n    window.zone = oldZone;\r\n  }\r\n```\r\n\r\nthe key is that if `zone.onError` is not defined we should not catch the exception and rethrow as not to destroy the stacktrace."}}