I’m catching an exception and I want to pass it further. I’ve tried this the 2 following ways:
except exceptions.MyException as e:
raise exceptions.MyException(message=e.message)
and:
except exceptions.MyException as e:
raise e(message=e.message)
further, I catch it as this:
except ArticleNotAcceptable as e:
Messages.flash(e.message)
While the first version works fine, the second doesn’t – it causes 'NoneType' object has no attribute 'id' that doesn’t tell me much. Can anyone please explain to me why?
>Solution :
exceptions.MyException is a class. e is an instance of MyException. You can call the class to get another instance of MyException. You cannot call an instance to get another instance.