Skip to content

Totle: Unhandled errors in checkReply #130

@samholmes

Description

@samholmes

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions