I wanted to create my own Python exception class, like this:
class MyException(BaseException):
def __init__(self, errno, address):
if errno == 10048:
mess = str(address) + ' is already in use'
else:
mess = 'Unable to open ' + str(address)
BaseException.__init__(mess)
but when the program got to the call to BaseException.__init__()
, I got this traceback:
BaseException.__init__(mess)
TypeError: descriptor '__init__' requires a 'exceptions.BaseException' object but received a 'str'
I thought that BaseException would take any set of arguments. Also, how I am supposed to pass an 'exceptions.BaseException' object into exceptions.BaseException's constructor?