Skip to content

Commit

Permalink
tmp fix errors on ubuntu
Browse files Browse the repository at this point in the history
  • Loading branch information
valpinkman committed Jan 16, 2025
1 parent 3466885 commit 693e0d2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
10 changes: 10 additions & 0 deletions libs/ledger-live-common/src/deviceSDK/transports/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
BluetoothRequired,
CantOpenDevice,
DeviceHalted,
DeviceMangementKitError,
FirmwareOrAppUpdateRequired,
PairingFailed,
PeerRemovedPairing,
Expand Down Expand Up @@ -266,6 +267,15 @@ const initialErrorRemapping = (error: unknown, context?: TraceContext) => {
}
}

// HANDLE DMK ERRORS
if (error && typeof error === "object" && "_tag" in error) {
const message =
"originalError" in error && typeof error.originalError === "object"
? ((error.originalError as Error).message as string)
: (error._tag as string);
mappedError = new DeviceMangementKitError(error._tag as string, message);
}

trace({
type: LOG_TYPE,
message: `Initial error remapping: ${error}`,
Expand Down
11 changes: 11 additions & 0 deletions libs/ledger-live-common/src/hw/deviceAccess.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
DeviceHalted,
PeerRemovedPairing,
PairingFailed,
DeviceMangementKitError,
} from "@ledgerhq/errors";
import { LocalTracer, TraceContext, trace } from "@ledgerhq/logs";
import { getEnv } from "@ledgerhq/live-env";
Expand All @@ -32,6 +33,15 @@ const initialErrorRemapping = (error: unknown, context?: TraceContext) => {
}
}

// HANDLE DMK ERRORS
if (error && typeof error === "object" && "_tag" in error) {
const message =
"originalError" in error && typeof error.originalError === "object"
? ((error.originalError as Error).message as string)
: (error._tag as string);
mappedError = new DeviceMangementKitError(error._tag as string, message);
}

trace({
type: LOG_TYPE,
message: `Initial error remapping: ${error}`,
Expand All @@ -46,6 +56,7 @@ let errorRemapping = e => throwError(() => e);
export const setErrorRemapping = (f: (arg0: Error) => Observable<never>): void => {
errorRemapping = f;
};

const never = new Promise(() => {});

/**
Expand Down
8 changes: 8 additions & 0 deletions libs/ledgerjs/packages/errors/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,14 @@ export class LockedDeviceError extends TransportStatusError {
}
}

export class DeviceMangementKitError extends Error {
constructor(name: string, message: string) {
super(message);
this.name = name;
Object.setPrototypeOf(this, DeviceMangementKitError.prototype);
}
}

// Represents the type of the class TransportStatusError and its children
export type TransportStatusErrorClassType = typeof TransportStatusError | typeof LockedDeviceError;

Expand Down
2 changes: 1 addition & 1 deletion libs/live-dmk/.unimportedrc.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"entry": ["src/index.tsx"],
"entry": ["src/index.ts"],
"ignorePatterns": ["**/node_modules/**", "**/*.test.{ts,tsx}"],
"ignoreUnused": ["react-dom"]
}
2 changes: 1 addition & 1 deletion libs/live-dmk/src/config/activeDeviceSession.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { BehaviorSubject } from "rxjs";
import { DeviceManagementKitTransport } from "src/transport/DeviceManagementKitTransport";
import { DeviceManagementKitTransport } from "../transport/DeviceManagementKitTransport";

export const activeDeviceSessionSubject: BehaviorSubject<{
sessionId: string;
Expand Down

0 comments on commit 693e0d2

Please sign in to comment.