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

#3354: Annotate when exceptions are caught but ignored #3356

Merged
merged 7 commits into from May 1, 2018
4 changes: 2 additions & 2 deletions bin/options.js
Expand Up @@ -40,8 +40,8 @@ function getOptions() {
process.argv = process.argv
.slice(0, 2)
.concat(opts.concat(process.argv.slice(2)));
} catch (err) {
// ignore
} catch (ignore) {
// NOTE: should console.error() and throw the error
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What did you mean by this comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly what it says. Believe it's a shortcoming of existing code. If anything goes wrong parsing the "mocha.opts" file or splicing its pieces/parts back into the cmdline arguments, the error is silently discarded. This just seems wrong, so I made a note; figured it should at least be discussed (and hopefully fixed in different issue).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@plroebuck I got it. Thank you for the explanation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You concur about throw?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if an error occurs in the above, should that environment variable be set (L47)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think we should be emitting a warning here, at minimum--unless there's some Git or issue history that makes me think otherwise.

That env var should be set anyway, because it's only used to check whether or not getOptions() should be called.

But that's another issue.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.

}

process.env.LOADED_MOCHA_OPTS = true;
Expand Down
2 changes: 1 addition & 1 deletion lib/browser/progress.js
Expand Up @@ -112,7 +112,7 @@ Progress.prototype.draw = function(ctx) {
var w = ctx.measureText(text).width;

ctx.fillText(text, x - w / 2 + 1, y + fontSize / 2 - 1);
} catch (err) {
} catch (ignore) {
// don't fail if we can't render progress
}
return this;
Expand Down
2 changes: 1 addition & 1 deletion lib/runner.js
Expand Up @@ -244,7 +244,7 @@ Runner.prototype.fail = function(test, err) {
try {
err.stack =
this.fullStackTrace || !err.stack ? err.stack : stackFilter(err.stack);
} catch (ignored) {
} catch (ignore) {
// some environments do not take kindly to monkeying with the stack
}

Expand Down