@tryghost/mw-error-handler 0.1.5 → 0.1.6

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.
@@ -36,7 +36,8 @@ const messages = {
36
36
  HostLimitError: 'Host Limit error, cannot {action}.',
37
37
  DisabledFeatureError: 'Theme validation error, the {{{helperName}}} helper is not available. Cannot {action}.',
38
38
  UpdateCollisionError: 'Saving failed! Someone else is editing this post.'
39
- }
39
+ },
40
+ UnknownError: 'Unknown error - {name}, cannot {action}.'
40
41
  };
41
42
 
42
43
  /**
@@ -161,7 +162,11 @@ const prepareUserMessage = (err, req) => {
161
162
  userError.context = err.message;
162
163
  }
163
164
 
164
- userError.message = tpl(messages.userMessages[err.name], {action: action});
165
+ if (_.get(messages.userMessages, err.name)) {
166
+ userError.message = tpl(messages.userMessages[err.name], {action: action});
167
+ } else {
168
+ userError.message = tpl(messages.UnknownError, {action, name: err.name});
169
+ }
165
170
  }
166
171
  }
167
172
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/mw-error-handler",
3
- "version": "0.1.5",
3
+ "version": "0.1.6",
4
4
  "repository": "https://github.com/TryGhost/Utils/tree/main/packages/mw-error-handler",
5
5
  "author": "Ghost Foundation",
6
6
  "license": "MIT",
@@ -30,5 +30,5 @@
30
30
  "@tryghost/tpl": "^0.1.8",
31
31
  "lodash": "4.17.21"
32
32
  },
33
- "gitHead": "64b09915cbfd97d139bf8360a79b36a0f45fc552"
33
+ "gitHead": "02581faa5be4812fb49e7944dacabef383c71074"
34
34
  }