feat: include data path in error messages
This commit is contained in:
parent
80f2ea6521
commit
67a61f6d8a
|
@ -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}`;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue