Skip to content

Commit

Permalink
feat(Porthole): report when event listeners throw errors for debuggin…
Browse files Browse the repository at this point in the history
…g purposes (Porthole.error)

Currently, when a listern function throws an error the exception is *silently swallowed*.
Debugging information was added in order to improve developer experience.

Porthole.error(e) was also tweaked. Added an additional type check for `window.console.error`.
  • Loading branch information
Fábio Leandro committed Mar 6, 2015
1 parent 0102344 commit 96a5b92
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/porthole.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ iFrame proxy abc.com->abc.com: forwardMessageEvent(event)
* @private
*/
error: function(s) {
if (window.console !== undefined) {
if (typeof window.console !== undefined && typeof window.console.error === 'function') {
window.console.error('Porthole: ' + s);
}
}
Expand Down Expand Up @@ -231,6 +231,7 @@ iFrame proxy abc.com->abc.com: forwardMessageEvent(event)
try {
this.eventListeners[i](event);
} catch(e) {
Porthole.error(e);
}
}
}
Expand Down

0 comments on commit 96a5b92

Please sign in to comment.