Don't actually construct real Errors with stacktraces, for performance reasons
parent
696492df7f
commit
73838db4b5
@ -1,12 +1,19 @@
|
||||
"use strict";
|
||||
|
||||
const createError = require("create-error");
|
||||
// NOTE: We don't actually inherit from the real Error here, because collecting stacktraces is very expensive and largely useless for our purposes. Validatem's own error reporting is clear enough, and if not, that's a bug in Validatem anyway.
|
||||
function ValidationError(message, properties) {
|
||||
this.message = message;
|
||||
|
||||
module.exports = createError("ValidationError", {
|
||||
Object.assign(this, {
|
||||
path: [],
|
||||
// NOTE: The below are for potential future compatibility logic.
|
||||
___validatem_isValidationError: true,
|
||||
___validatem_errorVersion: 1
|
||||
});
|
||||
|
||||
Object.assign(this, properties);
|
||||
}
|
||||
|
||||
ValidationError.prototype.name = "ValidationError";
|
||||
|
||||
module.exports = ValidationError;
|
||||
module.exports.__modulePath = __dirname;
|
||||
|
Loading…
Reference in New Issue