mirror of
https://github.com/aljazceru/mutiny-web.git
synced 2025-12-27 10:54:21 +01:00
11 lines
308 B
TypeScript
11 lines
308 B
TypeScript
/// Sometimes we catch an error as `unknown` so this turns it into an Error.
|
|
export default function eify(e: unknown): Error {
|
|
if (e instanceof Error) {
|
|
return e;
|
|
} else if (typeof e === "string") {
|
|
return new Error(e);
|
|
} else {
|
|
return new Error("Unknown error");
|
|
}
|
|
}
|