|
function checkReply(reply: Object, request: EdgeSwapRequest) { |
|
if (reply.success === false) { |
|
const code = reply.response.code |
|
// unsupported tokens |
|
if (code === 1203) { |
|
throw new SwapCurrencyError( |
|
swapInfo, |
|
request.fromCurrencyCode, |
|
request.toCurrencyCode |
|
) |
|
} else if (code === 3100) { |
|
throw new InsufficientFundsError() |
|
} else if (code === 1201) { |
|
throw new NoAmountSpecifiedError() |
|
} |
|
} |
|
} |
The checkReply function doesn't handle all error cases, which causes type errors following its invocation on line 186.
Throwing an unexpected error with response details could be a solution. Though, I didn't see any generic error type in the core, perhaps one might need to be created.
I've observed error codes not included in the list of error codes defined in the Totle API documentation, so it's best to have a code path for any case not matched.
edge-exchange-plugins/src/swap/totle.js
Lines 86 to 102 in 6c45dc4
The
checkReplyfunction doesn't handle all error cases, which causes type errors following its invocation on line 186.Throwing an unexpected error with response details could be a solution. Though, I didn't see any generic error type in the core, perhaps one might need to be created.
I've observed error codes not included in the list of error codes defined in the Totle API documentation, so it's best to have a code path for any case not matched.