Use standardized API error format in tequilapi - #4920
Merged
Conversation
tadaskay
requested review from
Snawoot,
Waldz,
mdomasevicius,
soffokl and
tomasmik
as code owners
March 24, 2022 08:03
tomasmik
approved these changes
Mar 24, 2022
tadaskay
force-pushed
the
go-rest-errors
branch
from
March 24, 2022 21:06
8f0bf06 to
4109c62
Compare
tadaskay
force-pushed
the
go-rest-errors
branch
from
March 25, 2022 08:36
4109c62 to
544eaaa
Compare
n10ty
approved these changes
Mar 25, 2022
n10ty
reviewed
Mar 25, 2022
mdomasevicius
approved these changes
Mar 25, 2022
tadaskay
force-pushed
the
go-rest-errors
branch
4 times, most recently
from
March 25, 2022 21:32
bba645d to
133fd3f
Compare
tadaskay
force-pushed
the
go-rest-errors
branch
from
March 25, 2022 21:57
133fd3f to
e3bcb0a
Compare
Codecov Report
@@ Coverage Diff @@
## master #4920 +/- ##
==========================================
- Coverage 39.21% 39.17% -0.04%
==========================================
Files 357 356 -1
Lines 19214 19018 -196
==========================================
- Hits 7535 7451 -84
+ Misses 10948 10845 -103
+ Partials 731 722 -9
Continue to review full report at Codecov.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem definition
server returned error: Possible error: another server returned error: you get a very long sausage: where the useful message is: in the very end.Solution
APIErrorformat defined in mysteriumnetwork/go-rest;apierror.ErrorHandlermiddleware for Gin to forwardAPIErrors (that have been added togin.Contextin request scope usingc.Error()) to the caller and wrap any other type of errors. Returned content type isapplication/vnd.mysterium.error+json;apierror.Parse(*http.Response) *APIErrorto parse the incoming error response body based onContent-Type.Scope of this PR
identities, payments endpoints in Tequilapiall Tequilapi endpoints and requests.ClientRelated info
go-restinpilvytis: https://github.com/mysteriumnetwork/pilvytis/pull/492go-restinmysterium-vpn-js: Change API error format to standard go-rest mysterium-vpn-js#119Sample (with field validation):
{ "error": { "code": "validation_failed", "message": "Request validation failed", "detail": "Request validation failed: passphrase: 'passphrase' is required [required]", "fields": { "passphrase": { "code": "required", "message": "'passphrase' is required" } } }, "status": 400, "path": "/identities" }