Replies: 2 comments 6 replies
-
@gustavoguichard @danielweinmann opinions? |
Beta Was this translation helpful? Give feedback.
6 replies
-
I'll close this, documentation seems to be the way to go |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We usually transform errors in composables using
mapError
.I see a very common pattern:
The goal above is not so much to transform an error, but to add some additional context or pre-processing before sending the errors elsewhere.
The problem
It is very common for developers to skip the spread, and remove existing errors from the list when doing the above. So the code above would be naively written as:
Which is also an implementation I have seen in the wild. And hiding these details, despite looking like a good idea, hinder troubleshooting after the fact as it is very hard to know what we will need to debug a live system.
Perhaps we should create an incentive, in our API, for preserving the original errors.
A possible solution
A new combinator such as
appendErrors : (errors: Error[]) => Error[]
.This combinator, has the same signature as
mapError
but it just appends the errors returned to the original list. So we could write the simpler version of the examples above and still keep the full error history:Beta Was this translation helpful? Give feedback.
All reactions