Skip to content

Commit

Permalink
chore: better object fallback behaviour for casting errors (#1053)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and stainless-bot committed Sep 9, 2024
1 parent 5a34316 commit b7d4619
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,11 @@ const validatePositiveInteger = (name: string, n: unknown): number => {

export const castToError = (err: any): Error => {
if (err instanceof Error) return err;
if (typeof err === 'object' && err !== null) {
try {
return new Error(JSON.stringify(err));
} catch {}
}
return new Error(err);
};

Expand Down

0 comments on commit b7d4619

Please sign in to comment.