-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better error messages for decoding exceptions #372
Comments
Anyway, as it stands your decoders should pass bogus inputs through unchanged. Even if they throw instead, |
You're expecting for |
Nice point, although one could argue that a base-64 encoded value should not have such a liberal schema. I forget the details but the seqex transcoder implementation is also a bit awkward because of stuff like |
Yes, the schema of such a case should be less liberal, but I think it demonstrates the point. Is the suggestion of throwing a more informative exception too hard to implement? |
It could be done, but for all feature requests, we need to balance between code complexity, performance and code size for cljs. Current design is that transformers don't throw. Added |
Transformers could have some more documentation, especially around implementing custom ones. |
Looked at the code again. Individual transformers do not know the path they are attached to, but the So, adding an new option to allow custom exception handler in the chain would allow bit better errors, but not Adding path-information to transformer creation, would be a bigger (and breaking) change. Could be evaluated, at some point. |
I think documentation about how a custom transformer should behave and what are the consequences would've been enough to steer me in the right direction. While I don't like the concept of a decoder silently returning the value unchanged I can learn to live with it ;)
My mental model was a bit different. Since the decoder is a function and I'm passing it to the framework (you call me) I expected the caller to have context about where in the schema is it applying the decoding function, therefore being able to enrich the exception with schema metadata |
I have the same mental model, just that in the current implementation, the |
adding those would open up a better view into what happens in the chain - one could interleave a interceptor that logs the current path, in, schema, phase and value before and after. Reitit has similar request/response debug printer. This all would come with zero runtime perf penalty. But, a lot of work. Interested in a PR? |
Well the The documentation needs to be improved in any case; the nonvalidating best-effort model is not what I (and @xificurC?) would expect. |
Sorry but no. Documenting the behavior would be enough for now, I guess this isn't exactly a hot feature |
As per discussion in metosin#372
throws
which is easy to spot in this case, not with a map that has 10-20 fields with the same decoder. The stacktrace doesn't point back to the schema line (I don't think it can either) and the error message doesn't tell me which key is the culprit. If the error could be caught and wrapped with more debug information that would be very helpful. Currently I'm thinking of changing the decoders to not throw and return a bogus object carrying the input value so that I can find the culprit(s) through m/explain.
The text was updated successfully, but these errors were encountered: