Skip to content

Commit 0ef46b6

Browse files
Remove CanBridgeInitializationError custom error
It just made it harder to get the actual error and actual stack trace.
1 parent a0152c2 commit 0ef46b6

File tree

1 file changed

+24
-37
lines changed

1 file changed

+24
-37
lines changed

lib/binding.ts

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,6 @@ export enum ThreadPriority {
3333
PriorityError
3434
}
3535

36-
export class CanBridgeInitializationError extends Error {
37-
cause: any;
38-
39-
constructor(cause: any) {
40-
super("Failed to load the CANBridge native addon. This is likely a packaging problem, or perhaps the Visual Studio C++ redistributable package is not installed. See cause field for details.");
41-
this.cause = cause;
42-
}
43-
}
44-
4536
export class CanBridge {
4637
getDevices: () => Promise<CanDeviceInfo[]>;
4738
registerDeviceToHAL: (descriptor:string, messageId:Number, messageMask:number) => number;
@@ -67,34 +58,30 @@ export class CanBridge {
6758
ackHeartbeats: () => void;
6859

6960
constructor() {
70-
try {
71-
const addon = require('node-gyp-build')(path.join(__dirname, '..'));
72-
73-
this.getDevices = promisify(addon.getDevices);
74-
this.registerDeviceToHAL = addon.registerDeviceToHAL;
75-
this.unregisterDeviceFromHAL = promisify(addon.unregisterDeviceFromHAL);
76-
this.receiveMessage = addon.receiveMessage;
77-
this.openStreamSession = addon.openStreamSession;
78-
this.readStreamSession = addon.readStreamSession;
79-
this.closeStreamSession = addon.closeStreamSession;
80-
this.getCANDetailStatus = addon.getCANDetailStatus;
81-
this.sendCANMessage = addon.sendCANMessage;
82-
this.sendHALMessage = addon.sendHALMessage;
83-
this.initializeNotifier = addon.initializeNotifier;
84-
this.waitForNotifierAlarm = promisify(addon.waitForNotifierAlarm);
85-
this.stopNotifier = addon.stopNotifier;
86-
this.writeDfuToBin = promisify(addon.writeDfuToBin);
87-
this.openHALStreamSession = addon.openHALStreamSession;
88-
this.readHALStreamSession = addon.readHALStreamSession;
89-
this.closeHALStreamSession = addon.closeHALStreamSession;
90-
this.setThreadPriority = addon.setThreadPriority;
91-
this.setSparkMaxHeartbeatData = addon.setSparkMaxHeartbeatData;
92-
this.startRevCommonHeartbeat = addon.startRevCommonHeartbeat;
93-
this.ackHeartbeats = addon.ackHeartbeats;
94-
this.stopHeartbeats = addon.stopHeartbeats;
95-
} catch (e: any) {
96-
throw new CanBridgeInitializationError(e);
97-
}
61+
const addon = require('node-gyp-build')(path.join(__dirname, '..'));
62+
63+
this.getDevices = promisify(addon.getDevices);
64+
this.registerDeviceToHAL = addon.registerDeviceToHAL;
65+
this.unregisterDeviceFromHAL = promisify(addon.unregisterDeviceFromHAL);
66+
this.receiveMessage = addon.receiveMessage;
67+
this.openStreamSession = addon.openStreamSession;
68+
this.readStreamSession = addon.readStreamSession;
69+
this.closeStreamSession = addon.closeStreamSession;
70+
this.getCANDetailStatus = addon.getCANDetailStatus;
71+
this.sendCANMessage = addon.sendCANMessage;
72+
this.sendHALMessage = addon.sendHALMessage;
73+
this.initializeNotifier = addon.initializeNotifier;
74+
this.waitForNotifierAlarm = promisify(addon.waitForNotifierAlarm);
75+
this.stopNotifier = addon.stopNotifier;
76+
this.writeDfuToBin = promisify(addon.writeDfuToBin);
77+
this.openHALStreamSession = addon.openHALStreamSession;
78+
this.readHALStreamSession = addon.readHALStreamSession;
79+
this.closeHALStreamSession = addon.closeHALStreamSession;
80+
this.setThreadPriority = addon.setThreadPriority;
81+
this.setSparkMaxHeartbeatData = addon.setSparkMaxHeartbeatData;
82+
this.startRevCommonHeartbeat = addon.startRevCommonHeartbeat;
83+
this.ackHeartbeats = addon.ackHeartbeats;
84+
this.stopHeartbeats = addon.stopHeartbeats;
9885
}
9986
}
10087

0 commit comments

Comments
 (0)