Add descriptive hints to DASP connection errors
Authentication failures now show "check username and password", busy devices say "device is busy", etc. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+1
-1
@@ -8,7 +8,7 @@ so later rebinding would only ever be seen by the module that did it.
|
|||||||
import configparser
|
import configparser
|
||||||
import os
|
import os
|
||||||
|
|
||||||
VERSION = "0.0.0.102"
|
VERSION = "0.0.0.103"
|
||||||
PROPERTIES_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "editor.properties")
|
PROPERTIES_FILE = os.path.join(os.path.dirname(os.path.abspath(__file__)), "editor.properties")
|
||||||
DEFAULT_GRID_SIZE = 10
|
DEFAULT_GRID_SIZE = 10
|
||||||
DEFAULT_ADD_TIMESTAMP = True
|
DEFAULT_ADD_TIMESTAMP = True
|
||||||
|
|||||||
@@ -101,9 +101,18 @@ def _trace(direction, msg, datagram=None):
|
|||||||
print(f"[DASP] {ts} {direction} {name}{seq}{ack} payload={plen}{hexdump}")
|
print(f"[DASP] {ts} {direction} {name}{seq}{ack} payload={plen}{hexdump}")
|
||||||
|
|
||||||
|
|
||||||
|
_ERROR_HINTS = {
|
||||||
|
ERR_NOT_AUTHENTICATED: " - check username and password",
|
||||||
|
ERR_BUSY: " - device is busy",
|
||||||
|
ERR_INCOMPATIBLE_VERSION: " - incompatible protocol version",
|
||||||
|
ERR_DIGEST_NOT_SUPPORTED: " - digest algorithm not supported",
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class DaspException(Exception):
|
class DaspException(Exception):
|
||||||
def __init__(self, msg, error_code=-1):
|
def __init__(self, msg, error_code=-1):
|
||||||
super().__init__(msg)
|
hint = _ERROR_HINTS.get(error_code, "")
|
||||||
|
super().__init__(msg + hint)
|
||||||
self.error_code = error_code
|
self.error_code = error_code
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user