Skip to content

Commit

Permalink
feat: include data path in error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
ssube committed Sep 11, 2019
1 parent 80f2ea6 commit 67a61f6
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/utils/ajv/index.ts
Expand Up @@ -4,8 +4,18 @@ import { VisitorError } from '../../visitor/VisitorError';

export function friendlyError(err: ErrorObject): VisitorError {
return {
data: {},
data: {
err,
},
level: 'error',
msg: err.message || err.keyword,
msg: friendlyErrorMessage(err),
};
}

export function friendlyErrorMessage(err: ErrorObject): string {
if (err.message) {
return `${err.dataPath} ${err.message}`;
} else {
return `${err.dataPath} ${err.keyword}`;
}
}

0 comments on commit 67a61f6

Please sign in to comment.