Merged in fix/warmup-not-throwing (pull request #3179)

fix: warmup threw error

* fix: warmup threw error

* .


Approved-by: Linus Flood
This commit is contained in:
Joakim Jäderberg
2025-11-19 13:49:44 +00:00
parent ac5fdc64a9
commit 0e66f1b6de
5 changed files with 89 additions and 74 deletions

View File

@@ -0,0 +1,11 @@
export type SafeTryResult<T> = Promise<
[T, undefined] | [undefined, Error | unknown]
>
export async function safeTry<T>(func: Promise<T>): SafeTryResult<T> {
try {
return [await func, undefined] as const
} catch (err) {
return [undefined, err instanceof Error ? err : (err as unknown)] as const
}
}