Skip to content

fix: display the response error message instead of the axios error#1392

Open
Ikari-Shinji-re wants to merge 2 commits into
nextfrom
fix/rc-122-show-response-error-instead-of-axios-error
Open

fix: display the response error message instead of the axios error#1392
Ikari-Shinji-re wants to merge 2 commits into
nextfrom
fix/rc-122-show-response-error-instead-of-axios-error

Conversation

@Ikari-Shinji-re
Copy link
Copy Markdown
Member

@Ikari-Shinji-re Ikari-Shinji-re commented May 11, 2026

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)

  • Updated the prettifyErrorMessage helper to check whether the error is an Axios error.
  • If the error is an Axios error, we now return the error field from the response object instead of the default Axios error message.

How did you test this change?

Override the /tx/create response with the following:

status code: 400

{
  "ok": false,
  "error": "failed for test",
  "errorCode": 1234,
  "traceId": 123456,
  "transaction": null
}

Steps:

  1. Select a route for a swap.
  2. Start the swap flow.

Expected result:
The displayed error message should be "failed for test" from the response object, instead of the Axios error mess

You can also verify this by trying this route on XO Swap:
/?fromBlockchain=ARBITRUM&fromToken=USDT--0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9&toBlockchain=TRON&toToken=USDT--TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t&fromAmount=10

  • Test A
  • Test B

Checklist:

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • Implemented a user interface (UI) change, referencing our Figma design to ensure pixel-perfect precision.

Copy link
Copy Markdown
Member

@nikaaru nikaaru left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants