Mapping Errors while Preserving Original Error: Handling Errors in TypeScript
What pattern do you use when you want to map an error to another type but preserve the original error? For example
Adding a field to SaveFailedError doesn't seem ideal because there's no guarantee that all my errors conform to that shape which makes general error processing (logging, reporting to sentry) more difficult. It seems like a job for
Is there an established pattern for this case?
Adding a field to SaveFailedError doesn't seem ideal because there's no guarantee that all my errors conform to that shape which makes general error processing (logging, reporting to sentry) more difficult. It seems like a job for
Cause but I'm not sure how best to use it.Is there an established pattern for this case?
