sarlink-portal/utils/tryCatch.ts
i701 aa18484475
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 13m55s
refactor: add tryCatch utility for error handling, update device-related components and types, and clean up unused code in payment actions
2025-04-05 16:07:11 +05:00

9 lines
203 B
TypeScript

export async function tryCatch<T, E = Error>(promise: T | Promise<T>) {
try {
const data = await promise;
return [null, data] as const;
} catch (error) {
return [error as E, null] as const;
}
}