Simply extend your error-class with an __init__
and an __str__
method.
Example:
class DataCollectorError(Exception):
def __init__(self, msg=''):
self.msg = msg
log(msg) # use your logging things here
def __str__(self):
return self.msg
Use msg=''
because then you don't need to always specify a message.