panda3d
panda3d copied to clipboard
Notifier should throw a custom exception instead of the base Exception class
Description
I don't know if this is a bug or an enhancement, I think it's kinda both
https://github.com/panda3d/panda3d/blob/master/direct/src/directnotify/Notifier.py#L119 <-- this code defaults to throwing a base exception instead of a custom NotifierException(Exception) or something like that
Use Case
being able to separately process exceptions called with notify.error? basically, the panda3d code I was running would throw a base Exception, so I had to process the base Exception, but also my own code had IndexError getting raised in it, which also would be considered an Exception and processed in that branch, so I couldn't find it out for a long time. It's pretty confusing and hard to find out in some cases
and yes I know you can pass specific exception classes there (that is how I fixed the bug), but it still should default to something less generic than Exception
Hey I thought I could look at some issues, maybe fix one. I don't really understand the problem (or the use of notifier in this case).
It's a logger/logging function that you set up to write things to file when notable things happen?
If so I would expect it's use to be something like:
mynotifier=Notifier()
try:
this=1
that=2
1/0
except Exception as my_exception_type:
mynotifier.error("my message", my_exception_type)
In other words, I can see how a more specific error type would be useful but I don't see how the notifier is supposed to catch or detect which error type to use?