g1t/apps/sudo/app/lib/settle.ts
Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| A menu shaped by how g1t works, Soon pages for every promise, and sudo for sales | 1 | /** |
| 2 | * A call whose failure should not take the whole page down: the page | |
| 3 | * shows what it has and says what did not answer. No Workers imports. | |
| 4 | */ | |
| 5 | export type Settled<T> = { ok: true; value: T } | { ok: false; error: string }; | |
| 6 | ||
| 7 | export async function settle<T>(promise: Promise<T>): Promise<Settled<T>> { | |
| 8 | try { | |
| 9 | return { ok: true, value: await promise }; | |
| 10 | } catch (error) { | |
| 11 | return { ok: false, error: error instanceof Error ? error.message : String(error) }; | |
| 12 | } | |
| 13 | } |