fix(shared): ensureError should not bury original message
- if 'e', the original cause, is not an Error, it is buried by the fallback message. - this PR ensures that the original cause is included in the error message
This commit is contained in:
@@ -9,7 +9,11 @@ export function ensureError(
|
||||
fallbackMessage?: string
|
||||
): Error | UnexpectedErrorStructureError {
|
||||
if (e instanceof Error) return e
|
||||
return new UnexpectedErrorStructureError(fallbackMessage)
|
||||
return new UnexpectedErrorStructureError(
|
||||
`${fallbackMessage}${
|
||||
e !== null && e !== undefined ? `Cause: ${JSON.stringify(e)}` : ''
|
||||
}`
|
||||
)
|
||||
}
|
||||
|
||||
// this makes sure that a case is breaking in typing and in runtime too
|
||||
|
||||
Reference in New Issue
Block a user