proudmonkey / AutoWrapper

A simple, yet customizable global exception handler and Http response wrapper for ASP.NET Core APIs.
MIT License
679 stars 82 forks source link

TransactionId (or ErrorId) in the output to support lookup in log files? #85

Open abelfiore opened 3 years ago

abelfiore commented 3 years ago

In a production environment, when exceptions get thrown, or errors occur, it can be good to hide the complexity of the problem (stack trace, etc) and give a vague response instead. AutoWrapper seems to support this with the IsDebug flag. However, it would be really nice to also provide something like a TransactionId (or ErrorId for errors?) so that API developers can easily isolate and analyze the problem in the log files. Does AutoWrapper currently support a way to do this? It looks like you can define custom response schema, but can that custom schema be automatically returned during an exception - rather than making an explicit throw?

proudmonkey commented 3 years ago

AutoWrapper doesn't support adding TransactionId/ErrorId automatically at this point. However, you can use ErrorCode parameter of the ApiException object to pass your own ErrorId.

abelfiore commented 3 years ago

Not ideal, but that is an option. Is there some way for me to do this in one place, rather than repeating this logic everywhere?

proudmonkey commented 3 years ago

Not at the moment. I'll tag this as feature enhancement for future release. Thank you.

abelfiore commented 3 years ago

Sounds great. Would love to see a TransactionId baked in for all requests. Really enjoying your library so far. Great job!