Skip to content

Instantly share code, notes, and snippets.

@caolan93
caolan93 / try-catch.ts
Created May 13, 2025 08:19 — forked from t3dotgg/try-catch.ts
Theo's preferred way of handling try/catch in TypeScript
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};