InstallError and CAPIError classes

now subclass VMError

minor version bump
This commit is contained in:
onyx-and-iris 2023-08-02 15:42:45 +01:00
parent 6b79c091e8
commit e96151cd5a
2 changed files with 16 additions and 13 deletions

View File

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "voicemeeter-api" name = "voicemeeter-api"
version = "2.3.7" version = "2.4.0"
description = "A Python wrapper for the Voiceemeter API" description = "A Python wrapper for the Voiceemeter API"
authors = ["onyx-and-iris <code@onyxandiris.online>"] authors = ["onyx-and-iris <code@onyxandiris.online>"]
license = "MIT" license = "MIT"

View File

@ -1,19 +1,22 @@
class InstallError(Exception): class VMError(Exception):
"""Exception raised when installation errors occur""" """Base VM Exception class. Raised when general errors occur."""
def __init__(self, msg):
class CAPIError(Exception): self.message = msg
"""Exception raised when the C-API returns error values"""
def __init__(self, fn_name, code, msg=None):
self.fn_name = fn_name
self.code = code
self.message = msg if msg else f"{fn_name} returned {code}"
super().__init__(self.message) super().__init__(self.message)
def __str__(self): def __str__(self):
return f"{type(self).__name__}: {self.message}" return f"{type(self).__name__}: {self.message}"
class VMError(Exception): class InstallError(VMError):
"""Exception raised when general errors occur""" """Exception raised when installation errors occur"""
class CAPIError(VMError):
"""Exception raised when the C-API returns an error code"""
def __init__(self, fn_name, code, msg=None):
self.fn_name = fn_name
self.code = code
super(CAPIError, self).__init__(msg if msg else f"{fn_name} returned {code}")