-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: handle auth and server error during swap #593
Conversation
🐝 PR preview in SwarmPreview URL: https://bah5acgzabqbnwqob5ozvrplcb6ncfg54etjgnx2fuu5fut4jqisj47i7b42q.bzz.link |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM, some suggestions which I will leave up to you.
src/pages/top-up/Swap.tsx
Outdated
getDesktopConfiguration(desktopUrl), | ||
'Unable to reach Desktop API. Is Swarm Desktop running?', | ||
'Unable to reach Desktop API - Swarm Desktop may not be running or API key is wrong', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to distinguish if the API key is wrong or Swarm Desktop server is not running, no?
src/utils/net.ts
Outdated
@@ -27,6 +27,12 @@ export async function sendRequest( | |||
method, | |||
headers, | |||
data, | |||
}).catch(error => { | |||
if (error?.response?.data) { | |||
throw Error(JSON.stringify(error.response.data)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would provide a bit nicer Error 😅 At least format it like suggested. Maybe include path of the request as well?
throw Error(JSON.stringify(error.response.data)) | |
throw Error(`Request failed! Response: ${JSON.stringify(error.response.data)}`) |
No description provided.