A TypeScript project lead wants to standardize error handling across microservices. What pattern best leverages TypeScript's type system for this?
-
A
Define a discriminated union Result type (Success | Failure) so callers must handle both cases
-
B
Use try/catch everywhere and type errors as 'any'
-
C
Throw custom Error subclasses and rely on documentation for handling
-
D
Return null for failures and let callers check for null