@openaddresses/batch-schema 2.1.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,10 @@
10
10
 
11
11
  ## Version History
12
12
 
13
+ ### v2.2.0
14
+
15
+ - :tada: Add support for errors with `status` set from external libraries (IE OpenAddresses/tilebase)
16
+
13
17
  ### v2.1.0
14
18
 
15
19
  - :tada: Add more detailed schema error messages
package/lib/error.js CHANGED
@@ -15,12 +15,21 @@ class PublicError {
15
15
 
16
16
  static respond(err, res, messages = []) {
17
17
  if (err instanceof PublicError) {
18
-
19
18
  res.status(err.status).json({
20
19
  status: err.status,
21
20
  message: err.safe,
22
21
  messages: messages
23
22
  });
23
+
24
+ // Duplicate Express supported Error extensions
25
+ } else if (err instanceof Error && (err.status || err.statusCode)) {
26
+ res.status(err.status).json({
27
+ status: err.status || err.statusCode,
28
+ message: err.message || 'Generic Error',
29
+ messages: messages
30
+ });
31
+
32
+ // Handle generic errors
24
33
  } else {
25
34
  console.error(err);
26
35
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@openaddresses/batch-schema",
3
3
  "root": true,
4
- "version": "2.1.0",
4
+ "version": "2.2.0",
5
5
  "description": "Strongly Validated JSON Schema support for address",
6
6
  "repository": "git@github.com:openaddresses/batch",
7
7
  "author": "ingalls <nick@ingalls.ca>",