import { TransportStatusError } from "@ledgerhq/errors";
import { getExchangeErrorMessage } from "@ledgerhq/hw-app-exchange";
export class CompleteExchangeError extends Error {
    step;
    title;
    constructor(step, title, message) {
        super(message);
        this.name = "CompleteExchangeError";
        this.title = title;
        this.step = step;
    }
}
export function convertTransportError(step, err) {
    if (err instanceof TransportStatusError) {
        const { errorName, errorMessage } = getExchangeErrorMessage(err.statusCode, step);
        return new CompleteExchangeError(step, errorName, 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