From ca347a0f21d8c08903ca5460cf5b4d856ae4849e Mon Sep 17 00:00:00 2001 From: Alin Eugen Deac Date: Wed, 21 Feb 2024 21:41:36 +0100 Subject: [PATCH] Use only message if error is instance of Error We do not know what kind of "message" might be inside generic objects! --- packages/support/src/exceptions/getErrorMessage.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/support/src/exceptions/getErrorMessage.ts b/packages/support/src/exceptions/getErrorMessage.ts index 7152fde7..8db2ecc0 100644 --- a/packages/support/src/exceptions/getErrorMessage.ts +++ b/packages/support/src/exceptions/getErrorMessage.ts @@ -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; } \ No newline at end of file