This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
Hi ! I've been making a stupid mistake while coding. After try/catch block i write code as if nothing has happened. For example i establish a network connection and retrieve some data from the server. Now after my try/catch block i'm using that data and go on as if nothing has happened. I don't think this is right. So i have come up with the following approach. Suppose i have a boolean value and it is set to true in the try block. In the catch block it is set to false. So after my try/catch block I should test this boolan value. If it is true then there should be further processing and if it is false an error message should be displayed. Do you think this is the right thing to do ? Regards Danish [ July 05, 2003: Message edited by: Danish Shaukat ]
I think that most likely, if the code following the catch block is something that shouldn't be executed after an exception, then either (a) your catch block is in the wrong place, or (b) you shouldn't catch the exception at all - declare it in the method's throws clause instead. (This will probably force you to decide whether or how to deal with the exception in some other method instead.) E.g. if you have