fix: display the response error message instead of the axios error#1392
Open
Ikari-Shinji-re wants to merge 2 commits into
Open
fix: display the response error message instead of the axios error#1392Ikari-Shinji-re wants to merge 2 commits into
Ikari-Shinji-re wants to merge 2 commits into
Conversation
1b2a7c4 to
d8ea702
Compare
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.
Summary
When a user tries to make a swap and the server cannot create the transaction, the API returns an HTTP error status along with an error message in the response body. Previously, we incorrectly displayed the HTTP library (Axios) error instead of the server-provided error message.
Fixes # (issue)
prettifyErrorMessagehelper to check whether the error is an Axios error.Axioserror, we now return theerrorfield from the response object instead of the default Axios error message.How did you test this change?
Override the
/tx/createresponse with the following:status code:
400{ "ok": false, "error": "failed for test", "errorCode": 1234, "traceId": 123456, "transaction": null }Steps:
Expected result:
The displayed error message should be
"failed for test"from the response object, instead of theAxioserror messYou can also verify this by trying this route on XO Swap:
/?fromBlockchain=ARBITRUM&fromToken=USDT--0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9&toBlockchain=TRON&toToken=USDT--TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t&fromAmount=10Checklist: