Skip to content
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

Totle: Unhandled errors in checkReply #130

Open
samholmes opened this issue Apr 30, 2021 · 0 comments
Open

Totle: Unhandled errors in checkReply #130

samholmes opened this issue Apr 30, 2021 · 0 comments

Comments

@samholmes
Copy link
Contributor

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.

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

No branches or pull requests

1 participant