Skip to content

Instantly share code, notes, and snippets.

View tijnjh's full-sized avatar

tijn tijnjh

  • Utrecht, Netherlands
  • 16:21 (UTC +01:00)
View GitHub Profile
@t3dotgg
t3dotgg / try-catch.ts
Last active November 30, 2025 20:25
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;
};