Skip to content

Commit

Permalink
chore: add err name check for backwards compability
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Tkacz committed Aug 21, 2024
1 parent 6b10ffb commit 8ee2f5f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/errors/InternalError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,9 @@ export class InternalError<T = ErrorDetails> extends Error {

export function isInternalError(error: unknown): error is InternalError {
// biome-ignore lint/suspicious/noExplicitAny: checking for existence of prop outside or Error interface
return isError(error) && (error as any)[Symbol.for(INTERNAL_ERROR_SYMBOL_KEY)] === true
return (
isError(error) &&
((error as any)[Symbol.for(INTERNAL_ERROR_SYMBOL_KEY)] === true ||
error.name === 'InternalError')
)
}
4 changes: 3 additions & 1 deletion src/errors/PublicNonRecoverableError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ export class PublicNonRecoverableError<T = ErrorDetails> extends Error {
export function isPublicNonRecoverableError(error: unknown): error is PublicNonRecoverableError {
return (
// biome-ignore lint/suspicious/noExplicitAny: checking for existence of prop outside or Error interface
isError(error) && (error as any)[Symbol.for(PUBLIC_NON_RECOVERABLE_ERROR_SYMBOL_KEY)] === true
isError(error) &&
((error as any)[Symbol.for(PUBLIC_NON_RECOVERABLE_ERROR_SYMBOL_KEY)] === true ||
error.name === 'PublicNonRecoverableError')
)
}

0 comments on commit 8ee2f5f

Please sign in to comment.