Skip to content

Commit

Permalink
CLOUD-439 - Return error objects, rather than error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
tsigle committed Oct 17, 2024
1 parent 50a71ec commit f2c9b57
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/LintRulePack.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ class LintRulePack {
ruleResponse.errorCount += response.errorCount;

response.errors.forEach((err) => {
ruleResponse.errors.push(err.message);
ruleResponse.errors.push(err);
});
}

Expand Down
7 changes: 5 additions & 2 deletions test/rules/example-rule/ExampleRule.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ExampleRule extends LintRule {
runRule() {
try {
const dvFlow = this.mainFlow;
const someErrorCondition = false;
const someErrorCondition = true;

// Variation where this rule is ignored in any subflows
// const { allFlows } = this;
Expand All @@ -29,7 +29,10 @@ class ExampleRule extends LintRule {
// }

if (someErrorCondition) {
this.addError("example-error", { messageArgs: [dvFlow.flowId] });
this.addError("example-error", {
messageArgs: [dvFlow.flowId],
nodeId: "n1234",
});
}
} catch (err) {
this.addError("generic-error", { messageArgs: [`${err}`] });
Expand Down
36 changes: 26 additions & 10 deletions test/rules/example-rule/tests/Example.expect.json
Original file line number Diff line number Diff line change
@@ -1,29 +1,45 @@
{
"name": "PingOne DaVinci Linter",
"pass": true,
"errorCount": 0,
"pass": false,
"errorCount": 1,
"rulePackResults": [
{
"name": "@ping-identity/dvlint",
"pass": true,
"errorCount": 0,
"pass": false,
"errorCount": 1,
"lintResults": [
{
"flowId": "2291498df43a63457abad5d2d1fa4df9",
"flowName": "dv-rule-general-001",
"pass": true,
"errorCount": 0,
"errors": [],
"pass": false,
"errorCount": 1,
"errors": [
{
"code": "example-error",
"message": "Example Rule of flow '2291498df43a63457abad5d2d1fa4df9'",
"nodeId": "n1234",
"recommendation": "We recommend this example.",
"type": "best-practice"
}
],
"rulesApplied": [
"example-rule"
],
"ruleResults": [
{
"ruleId": "example-rule",
"ruleDescription": "Example Rule",
"pass": true,
"errorCount": 0,
"errors": []
"pass": false,
"errorCount": 1,
"errors": [
{
"code": "example-error",
"message": "Example Rule of flow '2291498df43a63457abad5d2d1fa4df9'",
"nodeId": "n1234",
"recommendation": "We recommend this example.",
"type": "best-practice"
}
]
}
],
"rulesIgnored": []
Expand Down

0 comments on commit f2c9b57

Please sign in to comment.