Skip to content

Instantly share code, notes, and snippets.

View MarwanShehata's full-sized avatar
🎯
"Luck is what happens when preparation meets opportunity.", Seneca

Marwan Shehata MarwanShehata

🎯
"Luck is what happens when preparation meets opportunity.", Seneca
View GitHub Profile
@MarwanShehata
MarwanShehata / testTryCatch.ts
Created March 20, 2025 18:24 — forked from mthomason/testTryCatch.ts
A fixed version of an tryCatchWrapper for TypeScript.
// Types for the result object with discriminated union
type Success<T> = {
data: T;
error: null;
};
type Failure<E> = {
data: null;
error: E;
};
@MarwanShehata
MarwanShehata / try-catch.ts
Created March 20, 2025 17:43 — 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;
};