try-catch

How to catch connection timeout exceptions from XSD-generated typed DataSets?

This might be a bit complicated, but bear with me. I have a Windows Forms app. It uses strongly typed DataSets via the XSD designer. I am running data access queries via an asynchronous thread, performed like so: // Calling it in code on the main thread: LoadDataList_WorkerCaller dataDelegate = new LoadDataList_WorkerCaller(LoadDataL...

can matlab catch signals from linux? SIGIO

does matlab have the capability to catch signals from linux? for example, the signal SIGIO (29) can be sent to a process with a lease on a file when another process attempts to open that file. from my testing, when I try kill -s 29 pid, where pid is the process ID of a running matlab window, the matlab process is killed. similarly,kill -...

C# common error handling

I'm writing a web service which is wrapper for a vendor's web service, and have a fairly detailed series of catch statements for a call to a vendors web service methods. I have two or three types of exceptions that I'm handling (System.Web.Services.Protocols.SoapException, System.ApplicationException, System.Exception...) I just reali...

Can i start a thread in a catch in JAVA

I am trying to solve the collatz conjecture. I am using HashMap and Vector classes. I have to iterate the loop 2 147 483 648 times, but after I store 8,438,409 values in HashMap I'm getting an OutOfMemoryError. I'm running the program in Eclipse and have set -Xmx1024m option, but it didn't help. So, I'm catching the above error and try...

Try Catch block in Siebel

I have a script which sends a set of records into a file. I'm using Try - Catch block to handle the exceptions. In the catch block I have a code where it has the pointer to next record. But this is not executing . Basically I wan to skip the bad record n move to next record. while(currentrecord) { try { writerecord event } catch { curr...

Why is "java.lang.OutOfMemoryError: Java heap space" not caught?

I have a thread in a Java web application that causes a java.lang.OutOfMemoryError: Java heap space exception, but the try/catch block does not catch the error. Sample code: private void doSomeWork() { try { processData(); //Causes OutOfMemoryError System.out.println("This line does not execute"); } ...

Merge catch blocks with exactly the same code?

Hi I want to merge the catch blocks in the following code for code reuse reasons: try { DoSomeInputOutput(); } catch (InvalidOperationException ex) { HandleKnownException1(ex); } catch (InvalidDataException ex) { HandleKnownException1(ex); } catch (ArgumentNullException ex) { HandleKnownException1(ex); } catch (Argument...

Programmatically suppressing exceptions in C#

I have the following try-catch statement and I do not want to not throw the exception if the message property contains 'My error' in the text. How can I programmatcially accomplish this? Also, would this be considered code-smell? try { } catch(Exception e) { if(e.Messages.Contains("My error")) { //want to display a frie...

Unhandled exception in try-catch

try { list = from XElement e in d.Descendants(wix + "File") where e.Attribute("Name").Value.Contains(temp.Name) && e.Parent.Parent.Attribute("Name").Value.Contains(temp.Directory.Name) select e; } catch (NullReferenceException e) { MessageBox.Show(e.Message); } catch (Exception e) { Mess...

Try Catch - not catching

Here's my problem. I have a middleware web service used by several web clients. The web service is a wrapper service that makes calls to several vendors' web services. The call to the vendor's web service is wrapped in a TryCatch but any exceptions generated aren't getting caught by my web service, they're getting caught in the client...

What is an exception in PHP for and what is try and catch?

I am pretty new to using object/classes in PHP and I am curious about EXCEPTIONS, TRY, and CATCH In the example below I have all 3 shown in use. Obviously an exception is some sort of way of triggering an error but I do not understand why? In the code below I could easily show some sort of error or something without the exception pa...

catch exception by pointer in C++

Hi, I found that there are three ways to catch an exception, what are the differences? 1) catch by value; 2) catch by reference; 3) catch by pointer; I only know that catch by value will invoke two copies of the object, catch by reference will invoke one. So how about catch by pointer? When to use catch by pointer? In addition to th...

Why can I write a generic catch statement in C# that does nothing?

Possible Duplicate: Why cant I catch a generic exception in C#? I have been reviewing and writing Circuit Breaker code recently. The following method compiles, but the catch block is never entered. I have plenty of work-arounds, and this isn't the only way to get the right behavior (filtering exceptions), but I'm curious why thi...

C# enabling menu item

hello. I have a try-catch statement in reference to downloading a file. When the file is downloaded, I then enable one of my menu items then turn off a timer set to retry the download in one minute. My problem is that for some reason my "trafficManagementToolStripMenuItem.Enabled = true;" line is activating the catch statement even tho...

When catching a general exception, how can I determine the original exception type?

When catching an exception in .net, you can have as many type-specific exception blocks as needed. But I usually try to have at least one "general" exception catch block. But is there a way to get the type of the "real" exception thrown that is caught by the generic exception handler, perhaps using reflection? For example, if I have C...

C++ retrieve exception information

I have a c++ dll which I need to debug. Due to the circumstances in which I am using the dll, I am unable to debug it via the calling application. So, I created a try -catch, where the catch writes the exception to a file. The line which needs to be debugged involves imported classes from a 3rd party dll, so I have no way of knowing wh...

Try/catch in Java

Could someone please give me a hint why this try and catch is not working? It throws a scanner exception instead of printing the message I expect. import java.util.*; import java.io.*; import java.math.*; import javax.swing.*; public class Main { public static void main(String[] args) { Boolean test = true; while (t...

Try..Catch blocks always expensive?

Possible Duplicate: Do try/catch blocks hurt performance when exceptions are not thrown? Hey everyone, Just a quick question about try..catch blocks. I've heard they're expensive to use and shouldn't be used as part of a program's flow. However, in order to validate email addresses, I'm using the following code. try ...

How many statements in a try/catch statement?

Should I put multiple statements in a try and then catch all possible exceptions, or should I put only one statement in the try statement? Example: try { MaybeThrowIOException(); MaybeThrowFooBarException(); return true; } catch (IOException e) { // ... } catch (FooBarException e) { // ... } Or try { MaybeThr...

Recording SQL Server call stack when reporting errors

This is a follow up to the question Nested stored procedures containing TRY CATCH ROLLBACK pattern? In the catch block I use a stored procedure to report (reraise) the error by reading from ERROR_MESSAGE(), ERROR_PROCEDURE(), ERROR_LINE(), etc. As described here I also have a check so that it can determine if the error has already been ...