Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion can/interfaces/systec/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self, result, func, arguments):
self.func = func
self.arguments = arguments

message = self._error_message_mapping.get(result, "unknown")
message = self._error_message_mapping.get(result.value, "unknown")
super().__init__(
message=f"Function {func.__name__} (called with {arguments}): {message}",
error_code=result.value,
Expand Down
16 changes: 16 additions & 0 deletions test/test_systec_exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from ctypes import c_ubyte

from can.interfaces.systec.constants import ReturnCode
from can.interfaces.systec.exceptions import UcanError


def test_ucan_error_accepts_ctypes_result_code() -> None:
def ucan_write_can_msg_ex() -> None:
pass

result = c_ubyte(ReturnCode.ERR_ILLPARAM)

error = UcanError(result, ucan_write_can_msg_ex, ("arg",))

assert error.error_code == ReturnCode.ERR_ILLPARAM
assert "wrong parameter handed over to the function" in str(error)