flagon-io/g1t

public

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t/apps/sudo/app/lib/settle.ts

13 lines476 bytesCodeBlame

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 sales1/**
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 */
5export type Settled<T> = { ok: true; value: T } | { ok: false; error: string };
6
7export 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}