error-or
error-or copied to clipboard
Adding metadata to errors
Hello,
one thing FluentResults has is the ability to add metadata. After switching to ErrorOr, I have to add the metadata inside ProblemDetailsFactory
, which is very cumbersome... Due to this libraries implementation I have not find a elegant way to attach metadata to the error directly.
Do you know a way to add metadata in a similar way like in FluentResults or another generic way I can use to add metadata to Error
. Or is it maybe even possible to add metadata to ErrorOr (maybe via generic Error
instead of hardcoded one...).
Thanks in advance 😀
Hmm, this is an interesting idea. What kind of metadata are we talking about? Is this a specific recurring object you want to attach to all errors? a string? Can you elaborate on the use case?
Different use cases:
- environment metadata (helpful if the customer gives you only a screenshot of an error)
- user context (session data, etc)
- working with background APIs you may want to know which component is the real culprit (or if it was a resillience error)
- compressed stacktrace, compressed binary log data
And this are only the ones on top of my head or ones I already have encountered.