From c77c6ecee91593ece9c708199f29069aa1429d68 Mon Sep 17 00:00:00 2001 From: zariiii9003 <52598363+zariiii9003@users.noreply.github.com> Date: Tue, 13 Sep 2022 17:05:09 +0200 Subject: [PATCH] provide meaningful error message --- can/interfaces/vector/canlib.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/can/interfaces/vector/canlib.py b/can/interfaces/vector/canlib.py index ae60c5754..7737a99d3 100644 --- a/can/interfaces/vector/canlib.py +++ b/can/interfaces/vector/canlib.py @@ -791,14 +791,24 @@ def get_application_config( hw_channel = ctypes.c_uint() _app_channel = ctypes.c_uint(app_channel) - xldriver.xlGetApplConfig( - app_name.encode(), - _app_channel, - hw_type, - hw_index, - hw_channel, - xldefine.XL_BusTypes.XL_BUS_TYPE_CAN, - ) + try: + xldriver.xlGetApplConfig( + app_name.encode(), + _app_channel, + hw_type, + hw_index, + hw_channel, + xldefine.XL_BusTypes.XL_BUS_TYPE_CAN, + ) + except VectorError as e: + raise VectorInitializationError( + error_code=e.error_code, + error_string=( + f"Vector HW Config: Channel '{app_channel}' of " + f"application '{app_name}' is not assigned to any interface" + ), + function="xlGetApplConfig", + ) from None return xldefine.XL_HardwareType(hw_type.value), hw_index.value, hw_channel.value @staticmethod