Fix exception when disconnecting
This commit is contained in:
parent
a60acb1381
commit
6c720bd8aa
2 changed files with 6 additions and 4 deletions
|
@ -32,7 +32,7 @@ class PortController {
|
|||
this.parser = this.port.pipe(new parsers.Readline({ delimiter: "\r\n" }));
|
||||
}
|
||||
|
||||
open(callback: (error:Error | null | undefined)=>void, onCloseCallback:(error:Error)=>void) {
|
||||
open(callback: (error:Error | null | undefined)=>void, onCloseCallback:(error:Error | null | undefined)=>void) {
|
||||
if (this.isOpen) {
|
||||
throw new Error("Port already open");
|
||||
}
|
||||
|
|
|
@ -25,10 +25,12 @@ const connect = (): ThunkResult<void> => async (dispatch, getState) => {
|
|||
dispatch(connectionFailure(error));
|
||||
}
|
||||
}, (error) => {
|
||||
if (error !== null && error !== undefined) {
|
||||
if (error.message === "Reading from COM port (ReadIOCompletion): Access denied") {
|
||||
dispatch(connectionFailure(new Error("Device disconnected")));
|
||||
dispatch(connectionFailure(new Error(`Device ${state.serialConnection.port} disconnected`)));
|
||||
dispatch(connectionEnd());
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Reference in a new issue