error-or icon indicating copy to clipboard operation
error-or copied to clipboard

Adding metadata to errors

Open kgnet88 opened this issue 1 year ago • 2 comments

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 😀

kgnet88 avatar Sep 06 '22 05:09 kgnet88

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?

amantinband avatar Sep 22 '22 12:09 amantinband

Different use cases:

  1. environment metadata (helpful if the customer gives you only a screenshot of an error)
  2. user context (session data, etc)
  3. working with background APIs you may want to know which component is the real culprit (or if it was a resillience error)
  4. compressed stacktrace, compressed binary log data

And this are only the ones on top of my head or ones I already have encountered.

kgnet88 avatar Sep 25 '22 21:09 kgnet88