Skip to content

Commit

Permalink
extend error message to try to communicate what failed #74
Browse files Browse the repository at this point in the history
  • Loading branch information
3ll3d00d committed May 17, 2024
1 parent 81c03da commit f2cc356
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
2 changes: 2 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ The web interface is usable from phones, tablets, laptops or desktops.

ezbeq and minidsp-rs run on Linux, Windows, or Mac operating systems. Basic instructions are provided for installation and setup on Raspberry Pi (running RaspberryOS/raspbian) and Windows. The RPi documentation may also be used on an x86 machine running a Debian-based linux distribution (Debian, Ubuntu, Mint, etc), with some slight tweaks.

NB: Python 3.11 is the minimum version supported.

The following requirements should be met before attempting an installation:

### MiniDSP:
Expand Down
6 changes: 5 additions & 1 deletion ezbeq/minidsp.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import yaml
from autobahn.exception import Disconnected
from autobahn.twisted import WebSocketClientFactory, WebSocketClientProtocol
from plumbum import ProcessExecutionError
from twisted.internet.protocol import ReconnectingClientFactory

from ezbeq.apis.ws import WsServer
Expand Down Expand Up @@ -616,7 +617,10 @@ def __do_run(self, config_cmds: List[str], slot: Optional[int], slot_change_dela
logger.info(
f"[{self.name}] Sending {len(config_cmds)} commands to slot {slot} using {exe} {kwargs if kwargs else ''}")
start = time.time()
code, stdout, stderr = exe.run(timeout=self.__cmd_timeout, **kwargs)
try:
code, stdout, stderr = exe.run(timeout=self.__cmd_timeout, **kwargs)
except ProcessExecutionError as e:
raise UnableToPatchDeviceError(f'minidsp cmd failed due to : {e.stderr}', False) from e
end = time.time()
logger.info(
f"[{self.name}] Sent {len(config_cmds)} commands to slot {slot} in {to_millis(start, end)}ms - result is {code}")
Expand Down
17 changes: 12 additions & 5 deletions ui/src/services/ezbeq.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,18 @@ class EzBeqService {
const response = await fetch(`${API_PREFIX}/1/devices/${device}/config/${slot}/active`, {
method: 'PUT'
});
return this._parse_resp(response);
}

_parse_resp = async (response) => {
if (!response.ok) {
throw new Error(`EzBeq.activateSlot failed, HTTP status ${response.status}`);
if (response.status >= 500) {
const j = await response.json();
const txt = j && 'message' in j ? j.message : response.status;
throw new Error(`EzBeq.activateSlot failed, review ezbeq.log for full details - ${txt}`);
} else {
throw new Error(`EzBeq.activateSlot failed, invalid request (${response.status})`);
}
}
return response.json();
}
Expand All @@ -140,10 +150,7 @@ class EzBeqService {
'Accept': 'application/json'
},
});
if (!response.ok) {
throw new Error(`EzBeq.activateSlot failed, HTTP status ${response.status}`);
}
return response.json();
return this._parse_resp(response);
}

createPatchPayload = (slotId, gains, entryId = null) => {
Expand Down

0 comments on commit f2cc356

Please sign in to comment.