You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have seen suggestions that custom exceptions should be defined in their own file, to make importing them easier. Certainly from r3d2.wave import UnphysicalSolution is not the most obvious, when playing with try/except tricks. However, I don't know how "fixed" this convention is.
Would it be more consistent to have UnphysicalSolutionError to match other exceptions?
The text was updated successfully, but these errors were encountered:
Hi both, I hope you don’t mind me giving my two cents.
On Ian’s points:
I would say that 1 is not fixed but it is something I’ve been encouraging in my team as a good practice. I think it depends on the generality of the exception. If it will be raised across many files, I would move it to an exceptions file. If it is very specific and probably only going to raised in one file, then that is probably it’s home. UnphysicalSolution probably falls into the first category as I suspect there are many places in your code where an unphysical solution may occur.
On 2, I would agree that a naming convention is useful. I tend to do something like AppropriateNameException but it seems that AppropriateNameError would be more consistent in this case.
A few thoughts:
import
ing them easier. Certainlyfrom r3d2.wave import UnphysicalSolution
is not the most obvious, when playing withtry
/except
tricks. However, I don't know how "fixed" this convention is.UnphysicalSolutionError
to match other exceptions?The text was updated successfully, but these errors were encountered: