nitropage
Version:
A free and open source, extensible visual page builder based on SolidStart.
16 lines (14 loc) • 358 B
text/typescript
export const attempt = async <T>(input: Promise<T>) => {
try {
return [undefined, await input] as const;
} catch (err) {
return [err as Error, undefined] as const;
}
};
export const attemptSync = <T>(input: () => T) => {
try {
return [undefined, input()] as const;
} catch (err) {
return [err as Error, undefined] as const;
}
};