UNPKG

scrivito

Version:

Scrivito is a professional, yet easy to use SaaS Enterprise Content Management Service, built for digital agencies and medium to large businesses. It is completely maintenance-free, cost-effective, and has unprecedented performance and security.

23 lines (19 loc) 396 B
type Outcome<T> = ErrorOutcome | SuccessOutcome<T>; interface ErrorOutcome { errorThrown: true; error: unknown; } interface SuccessOutcome<T> { errorThrown: false; result: T; } export function runAndCatchException<T>(fn: () => T): Outcome<T> { try { return { errorThrown: false, result: fn(), }; } catch (error) { return { errorThrown: true, error }; } }