Re: [issue2551083] Derive Roundup exceptions from common base class other than BaseException
"John P. Rouillard" <[email protected]>
| Newsgroups | gmane.comp.bug-tracking.roundup.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Robert: In message <[email protected]>, Robert Klonner writes: >In roundup/exceptions.py there are some exceptions defined which are derived >from BaseException. I have a use case where I have to handle those exceptions >but I can't because they are using BaseException directly. I would have to >catch it with "except BaseException:" which would result in also catching >signals like keyboard interrupts or system exits). IIRC BaseException was the way it was done in earlier 2.2 pythons. The code base is showing its age. I am interested in your use case. AFAIK you can always: from exceptions import * then use try: ... except (exception1, exception2, exception3 ...): (I may be off on the syntax but you get the idea). Then list each exception you want to catch. Clumsy but workable. However if a new exception is added you will need to change your code 8-(. I see Ralf is already on this ticket. Ralf are you working it? I think (as recommended) a: class RoundupException(Exception): pass and substituting BaseException/Exception in all class definitions with RoundupException makes sense and follows recommended exception hierarchy guidelines. Does anybody see a problem with this? Any cases where this change may break something? I would like to get this in the 2.0 beta release (was planning on starting the release sequence this weekend). Robert I assume you can test it for your use case? -- -- rouilj