How to use the @ledgerhq/errors.DisconnectedDeviceDuringOperation function in @ledgerhq/errors

To help you get started, we’ve selected a few @ledgerhq/errors examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LedgerHQ / ledgerjs / packages / react-native-hid / src / index.js View on Github external
return this.exchangeAtomicImpl(async () => {
      try {
        const apduHex = apdu.toString("hex");
        log("apdu", "=> " + apduHex);
        const resultHex = await NativeModules.HID.exchange(this.id, apduHex);
        const res = Buffer.from(resultHex, "hex");
        log("apdu", "<= " + resultHex);
        return res;
      } catch (error) {
        if (disconnectedErrors.includes(error.message)) {
          this.emit("disconnect", error);
          throw new DisconnectedDeviceDuringOperation(error.message);
        }
        throw error;
      }
    });
  }
github LedgerHQ / ledgerjs / packages / react-native-hw-transport-ble / src / BleTransport.js View on Github external
write = async (buffer: Buffer, txid?: ?string) => {
    log("ble-frame", "=> " + buffer.toString("hex"));
    try {
      await this.writeCharacteristic.writeWithResponse(
        buffer.toString("base64"),
        txid
      );
    } catch (e) {
      throw new DisconnectedDeviceDuringOperation(e.message);
    }
  };
github LedgerHQ / ledgerjs / packages / hw-transport-webhid / src / TransportWebHID.js View on Github external
}).catch(e => {
      if (e && e.message && e.message.includes("write")) {
        this._emitDisconnect(e);
        throw new DisconnectedDeviceDuringOperation(e.message);
      }
      throw e;
    });
github LedgerHQ / ledgerjs / packages / hw-transport-node-ble / src / TransportNodeBle.js View on Github external
write = async (buffer: Buffer) => {
    log("ble-frame", "=> " + buffer.toString("hex"));
    try {
      await write(this.writeCharacteristic, buffer);
    } catch (e) {
      throw new DisconnectedDeviceDuringOperation(e.message);
    }
  };
github LedgerHQ / ledger-live-common / src / api / socket.js View on Github external
const onDisconnect = e => {
      transport.off("disconnect", onDisconnect);
      o.error(new DisconnectedDeviceDuringOperation((e && e.message) || ""));
    };
    transport.on("disconnect", onDisconnect);
github LedgerHQ / ledgerjs / packages / hw-transport-webusb / src / TransportWebUSB.js View on Github external
}).catch(e => {
      if (e && e.message && e.message.includes("disconnected")) {
        this._emitDisconnect(e);
        throw new DisconnectedDeviceDuringOperation(e.message);
      }
      throw e;
    });