Skip to content

Commit 77ad1c3

Browse files
author
Elias Mulhall
committed
Do not throw Error object from Result.withException
Typescript requires that the input to `new Error` be a string. The withException function was passing data typed as `any` to the Error constructor, meaning non-string values were definitely accepted. Since we want to be able to throw any kind of error data, don't use Error.
1 parent 0c96f0b commit 77ad1c3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/result.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export const withException = <V>(r: Result<V, any>): V => {
8989
if (r.ok === true) {
9090
return r.result;
9191
} else {
92-
throw new Error(r.error);
92+
throw r.error;
9393
}
9494
};
9595

0 commit comments

Comments
 (0)