Skip to content

Commit

Permalink
fix(errors): internal error spawns caused an uncaught exception if th…
Browse files Browse the repository at this point in the history
…e error was not instance of
  • Loading branch information
Michael committed Dec 14, 2022
1 parent 7745224 commit 26b5ca7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lib/core/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,16 @@ export class UrbexError extends Error implements UrbexErrorType {
}

static createFromError<T extends typeof UrbexError>(this: T, error: Error): InstanceType<T> {
if (!(error instanceof Error)) {
error = new Error(error);
}

const instance = new this(error.message);
instance.stack = replaceCallStackWithName(error.stack, this.name);

if (error.stack) {
instance.stack = replaceCallStackWithName(error.stack, this.name);
}

instance.name = this.name;

if (UrbexError.isInstance(error)) {
Expand Down

0 comments on commit 26b5ca7

Please sign in to comment.