-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy patherrors.js
More file actions
65 lines (65 loc) · 1.93 KB
/
errors.js
File metadata and controls
65 lines (65 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const common_1 = require("./common");
class ValidationError extends Error {
}
exports.ValidationError = ValidationError;
class ConversionError extends ValidationError {
constructor(value, converter, details) {
super();
this.value = value;
this.converter = converter;
this.details = details;
this.message = this.reason;
}
get reason() {
return `${common_1.objToStr(this.value)} ${this.details} [${this.converter}].`;
}
}
exports.ConversionError = ConversionError;
class AssertionError extends ValidationError {
constructor(value, assertion, details) {
super();
this.value = value;
this.assertion = assertion;
this.details = details;
this.message = this.reason;
}
get reason() {
return `${common_1.objToStr(this.value)} ${this.details} [${this.assertion}].`;
}
}
exports.AssertionError = AssertionError;
class ValidatorError extends ValidationError {
constructor(validator, field, value, err) {
super();
this.validator = validator;
this.field = field;
this.value = value;
this.err = err;
this.message = this.reason;
}
get reason() {
let response = `in validator [${this.validator}] on field "${this.field}".\n`;
if (this.err instanceof ValidationError) {
response += this.err.reason;
}
else {
response += this.err.message;
}
return response;
}
}
exports.ValidatorError = ValidatorError;
class NotMatchAnyError extends ValidationError {
constructor(value) {
super();
this.value = value;
this.message = this.reason;
}
get reason() {
return `${common_1.objToStr(this.value)} does not match any validators.`;
}
}
exports.NotMatchAnyError = NotMatchAnyError;
//# sourceMappingURL=errors.js.map