catch-block

How to Avoid Throwing An Error When SQL Select Returns Nothing

I read somewhere that one should never use error conditions as normal program flow. Makes excellent sense to me... But C# application sitting on top of a MySQL db. I need to parse a string value into two parts, an ID, and a value. (The original data come from a Devonian database), then validate the value against a lookup table. So, a co...

Code is only executing in the debugger - MS Visual C#

I'm using Microsoft Visual C# 2008 Express Edition. (And I apologize - this is more of a MS Vis C# usability question than a strict programming question...) I wrote a little program. when I run it in MS VC# with the debugger, all is well. When I use the "click Once" to generate something to deploy (I'm using the "from a CD-ROM" optio...

try-catch block in Java - execution statements in catch code

Hello, I have a question about the order of the execution of statements in a catch block in Java. when I run the following class Test1 (see below), I expect to have as output first Hi!, then the result of the e.printStackTrace(); statement, and then Bye!. However, I never get this order. Please, look at the outputs, which I have pasted ...

Catching exceptions in Java

Hello, There are certain predefined exceptions in Java, which, if thrown, report that something serious has happened and you'd better improve your code, than catching them in a catch block (if I have understood it correctly). But still I find many programs in which I have the following: } catch (IOException e) { ... } catch (FileN...

Under C# how much of a performance hit is a try, throw and catch block

First of all, a disclaimer: I have experience in other languages, but am still learning the subtleties of C# On to the problem... I am looking at some code, which uses the try/catch blocks in a way that concerns me. When a parsing routine is called, rather than return an error code, the programmer used the following logic catch (Tcl...

Return statements in catch blocks

I have seen some developers use the return statement in a catch block. Why/when would this be a useful technique to employ? EDIT: I actually just saw the return keyword being used. Thanks ...

Questions regarding ordering of catch statements in catch block - compiler specific or language standard?

I am currently using Visual Studio Express C++ 2008, and have some questions about catch block ordering. Unfortunately, I could not find the answer on the internet so I am posing these questions to the experts. I notice that unless catch (...) is placed at the end of a catch block, the compilation will fail with error C2311. For example...

.Net: What is your confident approach in "Catch" section of try-catch block, When developing CRUD operations?

hi, I was wondering if there would be any confident approach for use in catch section of try-catch block when developing CRUD operations(specially when you use a Database as your data source) in .Net? well, what's your opinion about below lines? public int Insert(string name, Int32 employeeID, string createDate) { SqlConne...

Toast does not display when used in catch block

I noticed that a toast isn't displayed when it's used inside a catch block. Does anyone know how to show toasts when catching exceptions? An Example: try { // try to open a file } catch (FileNotFoundException e) { Toast.makeText(this, R.string.txt_file_not_found, Toast.LENGTH_LONG); return; // cancel processing } ...