flora-errors
Advanced tools
Comparing version 0.9.1 to 2.0.0-alpha.1
10
index.js
@@ -85,2 +85,10 @@ 'use strict'; | ||
class ValidationError extends RequestError { | ||
constructor(message, validation) { | ||
super(message); | ||
this.code = 'ERR_VALIDATION_ERROR'; | ||
this.validation = validation; | ||
} | ||
} | ||
/** | ||
@@ -101,2 +109,3 @@ * Converts an error object to a stringifyable object format for use | ||
if (err.code) error.code = err.code; | ||
if (err.validation) error.validation = err.validation; | ||
@@ -125,4 +134,5 @@ if (options.exposeErrors) { | ||
ConnectionError, | ||
ValidationError, | ||
FloraError, | ||
format | ||
}; |
{ | ||
"name": "flora-errors", | ||
"version": "0.9.1", | ||
"version": "2.0.0-alpha.1", | ||
"description": "Error definitions for Flora", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -50,4 +50,9 @@ # Flora Errors | ||
### ValidationError | ||
There is a problem validating input data. This is a special case of `RequestError`. HTTP status code `400`. | ||
Error code is `ERR_VALIDATION_ERROR`. Second parameter of constructor will be added as additional `validation` property. | ||
## License | ||
[MIT](LICENSE) |
8044
113
58
8