gorocket
gorocket copied to clipboard
Improved error handling
Fixes my issue: https://github.com/badkaktus/gorocket/issues/13
-
Embeds an ErrStatus struct, which contains all of the Rocket.Chat error response fields that can be populated under different scenarios.
-
The error handling approach is inspired by how Rocket.Chat's Go SDK handles REST errors, but extended to handle a couple of extra error response fields I have come across and add informative error messages.
-
Adds an option
WithDebug
, which will also include thedetails
field which is sometimes present in error responses. I didn't include this by default because you can get errors that could expose data in logs you didn't want to, like this for validation error's inputs:
{
"errorType": "error-input-is-not-a-valid-field",
"details": {
"method": "insertOrUpdateUser",
"input": "sdfsdf ;;; ; ; -- ; ; fsdf",
"field": "Username"
}
}
-
I also fixed up some function comments to be properly formatted Godoc docstrings.
-
This could be considered a breaking change if some consumers of this package want request errors to fail without returning an
err
, but as this is a v0 package we're fine to make breaking changes.
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.
This PR was closed because it has been stalled for 10 days with no activity.