-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.js
33 lines (26 loc) · 771 Bytes
/
error.js
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
'use strict';
/* jshint unused:false */
/**
* Generates req.validateError
* @param {String} message - Error message.
* @param {String} options.property - Property name that is being validated.
* @param {String} options.value - Field value.
* @param {String} options.modelValue - Model value.
* @return {Object}
*/
function ErrorGenerator(message, options) {
this.name = 'RequestValidationError';
this.message = message;
this.status = 400;
if (options.property) {
this.property = options.property;
}
if (options.value) {
this.value = options.value;
}
if (options.modelValue) {
this.modelValue = options.modelValue;
}
}
ErrorGenerator.prototype = Error.prototype;
exports.Generator = ErrorGenerator;