Skip to content

Commit

Permalink
Merge pull request #71 from HubSpot/streamline-error-messaging
Browse files Browse the repository at this point in the history
Streamline error messaging
  • Loading branch information
camden11 authored Dec 13, 2023
2 parents 963799c + 33556fc commit 7149116
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions errors/standardErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ export function throwError(error: BaseError): never {
throwStatusCodeError(error as StatusCodeError);
} else {
// Error or Error subclass
const name = error.name || 'Error';
const message = [i18n('errors.generic', { name })];
const message =
error.name && error.name !== 'Error'
? [i18n('errors.generic', { name: error.name })]
: [];
[error.message, error.reason].forEach(msg => {
if (msg) {
message.push(msg);
Expand Down
2 changes: 1 addition & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,6 @@
"generic": "The {{ messageDetail }} failed."
}
},
"generic": "A {{ name }} has occurred"
"generic": "{{ name }}:"
}
}

0 comments on commit 7149116

Please sign in to comment.