in reply to goto with some arguments
I also find this far, far from beautiful. It reminds me of the awful error handling in Visual Basic.
I think goto is a useful construct, but an error handler built on control reaching a label from multiple places, then reacting to a couple of globals (you've got them as globals) is a recipe for disaster. Imagine yourself staring at the output of your show_error_page routine, and realizing that the error_code and error_msg don't match. Now you have another problem: who clobbered them? An error handler whose context information can be changed from different places is too unreliable to be useful.
If all you're looking for is an error handling technique that can receive some state information and not return to the calling context, exceptions are a much better answer, as others have pointed out above.
|
|---|