import { TransportStatusError } from "@ledgerhq/errors";
import { getExchangeErrorMessage } from "@ledgerhq/hw-app-exchange";
export class CompleteExchangeError extends Error {
    step;
    constructor(step, message) {
        super(message);
        this.name = "CompleteExchangeError";
        this.step = step;
    }
}
export function convertTransportError(step, err) {
    if (err instanceof TransportStatusError) {
        const errorMessage = getExchangeErrorMessage(err.statusCode, step);
        return new CompleteExchangeError(step, errorMessage);
    }
    return err;
}
export function getSwapStepFromError(error) {
    if (error.step) {
        return error.step;
    }
    else if (error.name === "DisabledTransactionBroadcastError") {
        return "SIGN_COIN_TRANSACTION";
    }
    return "UNKNOWN_STEP";
}
//# sourceMappingURL=error.js.map