Skip to content
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

Merged
merged 1 commit into from
May 9, 2015

Conversation

amsul
Copy link
Contributor

@amsul 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

@amsul
Copy link
Contributor Author

amsul commented Apr 18, 2015

@boneskull continuing the PR from #1659

Cheers!

*/

Mocha.prototype.allowUncaught = function(){
this.options.allowUncaught = global.mocha.allowUncaught = true;
Copy link
Member

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.

Copy link
Contributor Author

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.

@boneskull boneskull added this to the v2.3.0 milestone Apr 19, 2015
allows unhandled exceptions to propagate in the browser
added tests for allowUncaught option
global error handler prints to dom with allowUncaught
@amsul amsul force-pushed the allow-uncaught-exceptions branch from 3d9908f to c627a3d Compare April 19, 2015 04:39
@amsul
Copy link
Contributor Author

amsul commented Apr 20, 2015

@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);
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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

@boneskull
Copy link
Member

@amsul Everything looks good here, thanks. Can you open another pr against the gh-pages branch to note the available option in the browser? There should be a (small) section for browser-only options.

boneskull added a commit that referenced this pull request May 9, 2015
Added option to allow unhandled exceptions to propagate in the browser (rel #1659)
@boneskull boneskull merged commit 23939a9 into mochajs:v2.3.0 May 9, 2015
@dasilvacontin
Copy link
Contributor

Nice, thanks guys! :)

@amsul
Copy link
Contributor Author

amsul commented Jun 10, 2015

@boneskull, @dasilvacontin added #1740 :)

@lolmaus
Copy link

lolmaus commented Dec 11, 2015

How do I use it in browser? I tried mocha.allowUncaught() in the console but it doesn't change anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants