-
Notifications
You must be signed in to change notification settings - Fork 515
Errors: Support a filter to control which errors are reported #728
Conversation
6968a3e
to
5192449
Compare
|
||
// Return false to exclude this error | ||
// Return true to report this error normally | ||
return false; |
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.
The logic behind false
was that it was like disallowing the propagation of the error to the reporter.
If enough people think true
should throw the current error away, then I'll change it.
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.
This is fine and a good description, but perhaps "writing a filter and writing a reporter" belong elsewhere in the docs.
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.
This is a good point; the readme is pretty cluttered as is. I'm going to create a wiki page and link to it.
@mrjoelkemp, nice work! Need a CLI option too, right? |
Nice work! CLI option would be nice. BTW Let's not merge before #731 please. |
5192449
to
73e9560
Compare
73e9560
to
55add29
Compare
55add29
to
aa766f8
Compare
aa766f8
to
3bb0b72
Compare
3bb0b72
to
4817187
Compare
4817187
to
2908a91
Compare
11260f5
to
7d6dc3d
Compare
typeof config.errorFilter === 'string' || config.errorFilter === null, | ||
'`errorFilter` option requires a string or null value' | ||
); | ||
this._errorFilter = require(config.errorFilter.replace('.js', '')); |
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.
This will fail for browser
-version. You should declare a method like _loadPlugin
and override it in NodeConfiguration
.
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.
We probably need to add some smoke tests for browser version, like with phantom, not sure if would need something more besides that
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.
Yeah, we should!
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.
Created - #757
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.
@mdevils This is a great catch. This implies that an errorFilter is a function in lib/config/configuration
and a string in lib/config/node-configuration
.
7d6dc3d
to
7556fdc
Compare
7556fdc
to
3957b9d
Compare
@@ -258,6 +270,10 @@ Configuration.prototype._processConfig = function(config) { | |||
this._esnextEnabled = Boolean(config.esnext); | |||
} | |||
|
|||
if (config.errorFilter) { | |||
this._loadErrorFilter(config.errorFilter); |
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.
@mdevils The fact that configuration jumps between its own functions and the overridden functions of node-configuration made this hard to follow and implement. I understand why this has to happen, but do you feel it would be more unclear if we only have lib/config/configuration
and use try/catch to determine if we're in the node or browser environment?
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.
if we only have lib/config/configuration and use try/catch to determine if we're in the node or browser environment?
I think this will make the code more complext and lead to the future breaks, because you will have to include some external modules with hacks (to disallow browserify include it), put many catches. So currently I think we have simpler solution.
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.
That's fair. Thanks for the insight.
3957b9d
to
34172b4
Compare
@mikesherov Please give this a final look over when you have a chance. Just need a thumbs up to merge this. Thanks in advance. |
* | ||
* @param {Function} filter | ||
*/ | ||
filterErrorList: function(filter) { |
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.
Seems like this function should simply be called filter
. errors.filterErrorList
is redundant.
34172b4
to
2ca671b
Compare
👍 LGTM to land. |
Yay! Thanks for reviewing, all. |
Great work Joel! On Saturday, November 15, 2014, Joel Kemp notifications@github.com wrote:
Mike Sherov |
Fixes #335