-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added option to allow unhandled exceptions to propagate in the browser (rel #1659) #1662
Conversation
amsul
commented
Apr 18, 2015
- added allowUncaught option (Option to let exceptions propagate #553)
- allows unhandled exceptions to propagate in the browser
- added tests for allowUncaught option
- global error handler prints to dom with allowUncaught
@boneskull continuing the PR from #1659 Cheers! |
*/ | ||
|
||
Mocha.prototype.allowUncaught = function(){ | ||
this.options.allowUncaught = global.mocha.allowUncaught = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, taking a closer look, I don't like this. We should be handling this option the same way we handle others.
Mocha.prototype.allowUncaught = function(){
this.options.allowUncaught = true;
return this;
};
Below, when you need to read the setting, you'll need to get it a different way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, in fact global.mocha.allowUncaught
doesn’t need to be set at all. The global error handler will still work fine this way in the browser.
allows unhandled exceptions to propagate in the browser added tests for allowUncaught option global error handler prints to dom with allowUncaught
3d9908f
to
c627a3d
Compare
@boneskull is there anything else that concerns you in this PR? |
|
||
function callFnAsync(fn) { | ||
fn.call(ctx, function(err){ | ||
if (err instanceof Error || toString.call(err) === "[object Error]") return done(err); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
got a toString
here and an Object.prototype.toString
below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't write this.. the lines were just moved into the new method named callFnAsync
.
I can make the changes if you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't worry about it
@amsul Everything looks good here, thanks. Can you open another pr against the |
Added option to allow unhandled exceptions to propagate in the browser (rel #1659)
Nice, thanks guys! :) |
@boneskull, @dasilvacontin added #1740 :) |
How do I use it in browser? I tried |