Knowledgebase: FAQ
I want to start use EL, but my project already contains many try/except blocks. What is the best way to catch those errors?
Posted by Alexander Alexeev on 02 April 2009 10:40
|
|
Actually it is better not to change anything. If you have already writed some try/except blocks then your code can handle errors by himself. There is no need to report these exceptions as bugs. The exceptions to this rule are: 1). Your code is very bad, in the sense that try/except just blocks/hides errors that you do not know how to handle. 2). You get a, say, message box due to your error handling code, but you still do not know/understand why. 3). For some reason you want to do an exception logging (not full error processing). If you have one of the mentioned special cases then: for 1 and 2 - you should either use catch handled exceptions feature OR call ShowLastExceptionData procedure manually from except handler. for 3 - you should manually call to GetLastExceptionCallStack/CallStackToStrings from except handler and log this text. As alternative you can also enable catch handled exceptions feature and disable error dialog and/or sending bug report for handled errors (see also: http://support.eurekalog.com/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=12 ). Adding raise to except block is usually not a good idea: your code can not expect exception coming from try/except block (since there were no raise before). See also EL docs: http://www.eurekalog.com/docs/ | |
|