Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
LuckySwap
interface
Commits
5c969429
Unverified
Commit
5c969429
authored
May 13, 2021
by
Moody Salem
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: show better errors
parent
d27c83b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
useSwapCallback.ts
src/hooks/useSwapCallback.ts
+15
-2
No files found.
src/hooks/useSwapCallback.ts
View file @
5c969429
...
...
@@ -133,8 +133,21 @@ function useSwapCallArguments(
},
[
account
,
allowedSlippage
,
chainId
,
deadline
,
library
,
recipient
,
routerContract
,
signatureData
,
trade
])
}
export
function
swapErrorToUserReadableMessage
(
error
:
{
reason
:
string
}):
string
{
switch
(
error
.
reason
)
{
/**
* This is hacking out the revert reason from the ethers provider thrown error however it can.
* This object seems to be undocumented by ethers.
* @param error an error from the ethers provider
*/
export
function
swapErrorToUserReadableMessage
(
error
:
any
):
string
{
let
reason
:
string
|
undefined
while
(
Boolean
(
error
))
{
reason
=
error
.
reason
??
error
.
message
??
reason
error
=
error
.
error
??
error
.
data
.
originalError
}
if
(
reason
?.
indexOf
(
'
execution reverted:
'
)
===
0
)
reason
=
reason
.
substr
(
'
execution reverted:
'
.
length
)
switch
(
reason
)
{
case
'
UniswapV2Router: EXPIRED
'
:
return
'
The transaction could not be sent because the deadline has passed. Please check that your transaction deadline is not too low.
'
case
'
UniswapV2Router: INSUFFICIENT_OUTPUT_AMOUNT
'
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment