Skip to content

Commit c3a5c7a

Browse files
authored
Provide meaningful error message for xlGetApplConfig error (hardbyte#1392)
1 parent 366e239 commit c3a5c7a

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

can/interfaces/vector/canlib.py

+18-8
Original file line numberDiff line numberDiff line change
@@ -791,14 +791,24 @@ def get_application_config(
791791
hw_channel = ctypes.c_uint()
792792
_app_channel = ctypes.c_uint(app_channel)
793793

794-
xldriver.xlGetApplConfig(
795-
app_name.encode(),
796-
_app_channel,
797-
hw_type,
798-
hw_index,
799-
hw_channel,
800-
xldefine.XL_BusTypes.XL_BUS_TYPE_CAN,
801-
)
794+
try:
795+
xldriver.xlGetApplConfig(
796+
app_name.encode(),
797+
_app_channel,
798+
hw_type,
799+
hw_index,
800+
hw_channel,
801+
xldefine.XL_BusTypes.XL_BUS_TYPE_CAN,
802+
)
803+
except VectorError as e:
804+
raise VectorInitializationError(
805+
error_code=e.error_code,
806+
error_string=(
807+
f"Vector HW Config: Channel '{app_channel}' of "
808+
f"application '{app_name}' is not assigned to any interface"
809+
),
810+
function="xlGetApplConfig",
811+
) from None
802812
return xldefine.XL_HardwareType(hw_type.value), hw_index.value, hw_channel.value
803813

804814
@staticmethod

0 commit comments

Comments
 (0)