Relative Content

Tag Archive for error-handling

Python – assert vs if & return

I am writing a script that does something to a text file (what it does is irrelevant for my question though). So before I do something to the file I want to check if the file exists. I can do this, no problem, but the issue is more that of aesthetics.

Partial recovery from an Exception [duplicate]

This question already has answers here: Efficient try / catch block usage? (6 answers) Is rethrowing an exception leaking an abstraction? (4 answers) Closed 10 years ago. I have seen Exception Handling blocks that they were throwing the recently caught Exception in the catch block. Something like: } catch ( Exception $e ) { // […]

Automating form error handling

I’m not sure if I’m being clever or making things more difficult. I’m working within a custom MVC framework, and within some of my “views” which contain forms I’m preserving input and styling errors as follows: