Skip to content

Commit

Permalink
feat: add a reference to the node a rule failed on
Browse files Browse the repository at this point in the history
This patch adds a `.node` reference to an errored rule result. This can be used to determine which node the rule errored on and will be helpful for debugging purposes.

Closes #1317.
  • Loading branch information
stephenmathieson committed Jan 16, 2019
1 parent 9225ae0 commit 4612754
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/core/base/audit.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,10 @@ function getDefferedRule(rule, context, options) {
description: 'An error occured while running this rule',
message: err.message,
stack: err.stack,
error: err
error: err,
// Add a reference to the node the rule failed on for easier debugging.
// See https://github.com/dequelabs/axe-core/issues/1317.
node: err.node || null
});
// resolve
resolve(errResult);
Expand Down
2 changes: 2 additions & 0 deletions lib/core/base/check.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Check.prototype.run = function(node, options, context, resolve, reject) {
context
);
} catch (e) {
// Save a reference to the node we errored on for futher debugging.
e.node = node;
reject(e);
return;
}
Expand Down

0 comments on commit 4612754

Please sign in to comment.