Handling Errors in TypeScript: Returning Custom Exceptions vs. Direct Errors
hi i want to know if returning unknownException is the right way to go or should i return the error directly ?
function use<T>(f: (db: DB) => Promise<T>) {
return Effect.tryPromise({
try: () => f(db),
catch(error) {
if (error instanceof postgres.PostgresError) {
return new DbError({ pgError: error });
}
return new UnknownException(error);
},
});
}