Recommendation on Mapping/Wrapping Errors in TypeScript

Whats your recommendation on mapping / wrapping errors? Lets say we have a repository that can fail a create operation with an UnknownDatabaseError | DatabaseConnectionError. Would you map those on the method level to something like CreateUserRecordError --> so the return type of the function becomes CreateUserRecordError | DatabaseConnectionError? It makes it clearer in the function signature but potentially makes error matching a LOT harder
Was this page helpful?