mirror of
https://github.com/onyx-and-iris/voicemeeter-api-python.git
synced 2024-11-23 19:40:46 +00:00
remove __str__ override in VMError
move error message for code -9 into CAPIError class
This commit is contained in:
parent
5aaa9aab71
commit
df473d89ae
@ -121,5 +121,5 @@ class CBindings(metaclass=ABCMeta):
|
||||
raise CAPIError(func.__name__, res)
|
||||
return res
|
||||
except CAPIError as e:
|
||||
self.logger_cbindings.exception(str(e))
|
||||
self.logger_cbindings.exception(f"{type(e).__name__}: {e}")
|
||||
raise
|
||||
|
@ -1,13 +1,6 @@
|
||||
class VMError(Exception):
|
||||
"""Base VM Exception class. Raised when general errors occur."""
|
||||
|
||||
def __init__(self, msg):
|
||||
self.message = msg
|
||||
super().__init__(self.message)
|
||||
|
||||
def __str__(self):
|
||||
return f"{type(self).__name__}: {self.message}"
|
||||
|
||||
|
||||
class InstallError(VMError):
|
||||
"""Exception raised when installation errors occur"""
|
||||
@ -16,7 +9,16 @@ class InstallError(VMError):
|
||||
class CAPIError(VMError):
|
||||
"""Exception raised when the C-API returns an error code"""
|
||||
|
||||
def __init__(self, fn_name, code, msg=None):
|
||||
def __init__(self, fn_name, code):
|
||||
self.fn_name = fn_name
|
||||
self.code = code
|
||||
super(CAPIError, self).__init__(msg if msg else f"{fn_name} returned {code}")
|
||||
if self.code == -9:
|
||||
message = " ".join(
|
||||
(
|
||||
f"no bind for {self.fn_name}.",
|
||||
"are you using an old version of the API?",
|
||||
)
|
||||
)
|
||||
else:
|
||||
message = f"{self.fn_name} returned {self.code}"
|
||||
super().__init__(message)
|
||||
|
@ -121,13 +121,7 @@ class Remote(CBindings):
|
||||
return self.call(self.bind_macro_button_is_dirty, ok=(0, 1)) == 1
|
||||
except AttributeError as e:
|
||||
self.logger.exception(f"{type(e).__name__}: {e}")
|
||||
ERR_MSG = (
|
||||
"no bind for VBVMR_MacroButton_IsDirty.",
|
||||
"are you using an old version of the API?",
|
||||
)
|
||||
raise CAPIError(
|
||||
"VBVMR_MacroButton_IsDirty", -9, msg=" ".join(ERR_MSG)
|
||||
) from e
|
||||
raise CAPIError("VBVMR_MacroButton_IsDirty", -9) from e
|
||||
|
||||
@property
|
||||
def ldirty(self) -> bool:
|
||||
@ -187,13 +181,7 @@ class Remote(CBindings):
|
||||
)
|
||||
except AttributeError as e:
|
||||
self.logger.exception(f"{type(e).__name__}: {e}")
|
||||
ERR_MSG = (
|
||||
"no bind for VBVMR_MacroButton_GetStatus.",
|
||||
"are you using an old version of the API?",
|
||||
)
|
||||
raise CAPIError(
|
||||
"VBVMR_MacroButton_GetStatus", -9, msg=" ".join(ERR_MSG)
|
||||
) from e
|
||||
raise CAPIError("VBVMR_MacroButton_GetStatus", -9) from e
|
||||
return int(c_state.value)
|
||||
|
||||
def set_buttonstatus(self, id_: int, val: int, mode: int) -> None:
|
||||
@ -208,13 +196,7 @@ class Remote(CBindings):
|
||||
)
|
||||
except AttributeError as e:
|
||||
self.logger.exception(f"{type(e).__name__}: {e}")
|
||||
ERR_MSG = (
|
||||
"no bind for VBVMR_MacroButton_SetStatus.",
|
||||
"are you using an old version of the API?",
|
||||
)
|
||||
raise CAPIError(
|
||||
"VBVMR_MacroButton_SetStatus", -9, msg=" ".join(ERR_MSG)
|
||||
) from e
|
||||
raise CAPIError("VBVMR_MacroButton_SetStatus", -9) from e
|
||||
self.cache[f"mb_{id_}_{mode}"] = int(c_state.value)
|
||||
|
||||
def get_num_devices(self, direction: str = None) -> int:
|
||||
|
Loading…
Reference in New Issue
Block a user