rajanadar / VaultSharp

A comprehensive cross-platform .NET Library for HashiCorp's Vault, a secret management tool
http://rajanadar.github.io/VaultSharp
Apache License 2.0
493 stars 134 forks source link

VaultApiExceptions could handle errors more neatly #278

Closed conrad-roux closed 1 year ago

conrad-roux commented 2 years ago

Describe the feature request or question VaultApiExceptions class is not returning coherent or nicely formatted data in the exception message. The response returns a json object and that gets sent as a json "blob" for the error. I would suggest that you rather read the body or something similar of the Vault Api response and then add that to an error message property. If you use Ilogger with something like Serilog or any other implementation, and try to read the exception message, the message says that an error occurred, instead of a nice description of what the error actually is, like unauthorized or permission denied or something more descriptive. This does get returned in the Vault Api response so it can easily be caught and read/written instead of just throwing a json object.

rajanadar commented 1 year ago

hi @conrad-roux

This is by design. In general, a server side api is notorious for 500 errors with and without a body, 503 like non app errors, 4xx errors where the body can be anything.

As a client, it is by design to not put too much over-smartness into the error messages and return the status code and array of messages sent by the server wherever possible. And to keep it very simple.

Please let me know any specific instance of improvement.