Skip to content

Commit

Permalink
Use only message if error is instance of Error
Browse files Browse the repository at this point in the history
We do not know what kind of "message" might be inside generic objects!
  • Loading branch information
aedart committed Feb 21, 2024
1 parent 4c7a6b6 commit ca347a0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/support/src/exceptions/getErrorMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
export function getErrorMessage(error: unknown, defaultMessage: string = 'unknown reason'): string
{
return (typeof error == 'object' && Reflect.has(error, 'message'))
return (typeof error == 'object' && error instanceof Error && Reflect.has(error, 'message'))
? error.message
: defaultMessage;
}

0 comments on commit ca347a0

Please sign in to comment.