Skip to content

Commit

Permalink
feat: some return errors from the API now properly throw
Browse files Browse the repository at this point in the history
  • Loading branch information
GriffinSauce committed Nov 5, 2022
1 parent b879a2f commit 0de502b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/BaseDevice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ export class BaseDevice {

debug(`Return response: ${response}`);
this.#busy = false;

// We don't know all error codes (yet) so this is rough detection
if (/(buffer|overflow|timeout|invalid)/gi.test(response)) {
throw new Error(response);
}
return response;
}

Expand Down

0 comments on commit 0de502b

Please sign in to comment.