UNPKG

1.16 kBJavaScriptView Raw
1const util = require("util");
2
3function ErrorType(defaultMessage, errorName) {
4 function newError(message) {
5 Error.call(this);
6 Error.captureStackTrace(this, this.constructor);
7
8 this.name = errorName;
9 this.message = message || defaultMessage;
10 }
11 util.inherits(newError, Error);
12 return newError;
13}
14
15module.exports = {
16 "MissingSchemaError": new ErrorType("Missing Schema", "MissingSchemaError"),
17 "InvalidParameter": new ErrorType("Invalid Parameter", "InvalidParameter"),
18 "InvalidParameterType": new ErrorType("Invalid Parameter Type", "InvalidParameterType"),
19 "UnknownAttribute": new ErrorType("The attribute can not be found", "UnknownAttribute"),
20 "InvalidType": new ErrorType("Invalid Type", "InvalidType"),
21 "WaitForActiveTimeout": new ErrorType("Waiting for table to be active has timed out", "WaitForActiveTimeout"),
22 "TypeMismatch": new ErrorType("There was a type mismatch between the schema and document", "TypeMismatch"),
23 "InvalidFilterComparison": new ErrorType("That filter comparison is invalid", "InvalidFilterComparison"),
24 "ValidationError": new ErrorType("There was an validation error with the document", "ValidationError"),
25};