exception

Should I use an exception specifier in C++?

In C++, you can specify that a function may or may not throw an exception by using an exception specifier. For example: void foo() throw(); // guaranteed not to throw an exception void bar() throw(int); // may throw an exception of type int void baz() throw(...); // may throw an exception of some unspecified type I'm doubtful about ac...

Exception getting past Application.ThreadException and AppDomain.CurrentDomain.UnhandledException

I'm having a problem with an application hanging and giving me the default "Please tell Microsoft about this problem" popup, instead of the "unhandled exception" dialog in the application. In the application code, the Application.ThreadException and AppDomain.CurrentDomain.UnhandledException are both redirected to a method which writes ...

What is the correct way to make a custom .NET Exception serializable?

More specifically, when the exception contains custom objects which may or may not themselves be serializable. Take this example: public class MyException : Exception { private readonly string resourceName; private readonly IList<string> validationErrors; public MyException(string resourceName, IList<string> validationErro...

Best way to catch a WCF exception in Silverlight?

I have a Silverlight 2 application that is consuming a WCF service. As such, it uses asynchronous callbacks for all the calls to the methods of the service. If the service is not running, or it crashes, or the network goes down, etc before or during one of these calls, an exception is generated as you would expect. The problem is, I d...

Why aren't variables declared in "try" in scope in "catch" or "finally"?

In C# and in Java (and possibly other languages as well), variables declared in a "try" block are not in scope in the corresponding "catch" or "finally" blocks. For example, the following code does not compile: try { String s = "test"; // (more code...) } catch { Console.Out.WriteLine(s); //Java fans: think "System.out.println" ...

How can I get the current exception in a WinForms TraceListener

I am modifying an existing WinForms app which is setup with a custom TraceListener which logs any unhandled errors that occur in the app. It seems to me like the TraceListener gets the message part of the exception (which is what gets logged), but not the other exception information. I would like to be able to get at the exception objec...

LINQ FormatException

I currently have an existing database and I am using the LINQtoSQL generator tool to create the classes for me. The tool is working fine for this database and there are no errors with that tool. When I run a LINQ to SQL query against the data, there is a row that has some invalid data somehow within the table and it is throwing a System....

WCF faults and exceptions

I'm writing a WCF service for the first time. The service and all of its clients (at least for now) are written in C#. The service has to do a lot of input validation on the data it gets passed, so I need to have some way to indicate invalid data back to the client. I've been reading a lot about faults and exceptions, wrapping excepti...

Which, and why, do you prefer Exceptions or Return codes?

My question is what do most developers prefer for error handling, Exceptions or Error Return Codes. Please be language(or language family) specific and why you prefer one over the other. I'm asking this out of curiosity. Personally I prefer Error Return Codes since they are less explosive and don't force user code to pay the exception p...

WCF - Overhead of throwing FaultExceptions within your service

I posted a question about using Messages versus Fault Exceptions to communicate business rules between services. I was under the impression it carried overhead to throw this exception over the wire, but considering it's just a message that get serialized and deserialized, they were in fact one and the same. But this got me thinking abo...

Reasons of getting a java.lang.VerifyError

I'm investigating the following java.lang.VerifyError java.lang.VerifyError: (class: be/post/ehr/wfm/application/serviceorganization/report/DisplayReportServlet, method: getMonthData signature: (IILjava/util/Collection;Ljava/util/Collection;Ljava/util/HashMap;Ljava/util/Collection;Ljava/util/Locale;Lorg/apache/struts/util/MessageRe˜̴M...

Java: Prevent NPE in MetalFileChooserUI$IndentIcon.getIconWidth ???

Hello, on Windows systems. I get the follwing NPE with the FileChooser. It is a known bug that is not fixed by sun yet. http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6342301 Does somebody know a workaround to prevent this exception? Thanks. André Exception in thread "AWT-EventQueue-2" java.lang.NullPointerException at javax....

How to catch all exceptions in Flex?

When I run a Flex application in the debug flash player I get an exception pop up as soon as something unexpected happened. However when a customer uses the application he does not use the debug flash player. In this case he does not get an exception pop up, but he UI is not working. So for supportability reasons, I would like to catch ...

How would you get the Sql Command objects for a Given TableAdaptor and SqlDataAdaptor in C# (.NET 2.0)

I am creating a generic error handling / logging class for our applications. The goal is to log the exception info, info about the class and function (as well as parameters) and if relevant, the information about the System.Data.SqlClient.SqlCommand object. I would like to be able to handle passing in SqlCommands, TableAdaptors, and Sql...

Rhino mocks ordered reply, throw exception problem

I'm trying to implement some retry logic if there is an exception in my code. I've written the code and now I'm trying to get Rhino Mocks to simulate the scenario. The jist of the code is the following: class Program { static void Main(string[] args) { MockRepository repo = new MockRepository(); ...

Invalid postback or callback argument

I have an ASP.net application that works fine in the development environment but in the production environment throws the following exception when clicking a link that performs a postback. Any ideas? Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="...

Exceptions: Is this a good practice?

This is written in PHP but it's really language agnostic. try { try { $issue = new DM_Issue($core->db->escape_string($_GET['issue'])); } catch(DM_Exception $e) { throw new Error_Page($tpl, ERR_NOT_FOUND, $e->getMessage()); } } catch(Error_Page $e) { die($e); } Is nested try, catch blocks a g...

What causes java.io.CharConversionException with EOF or isHexDigit messages in Tomcat?

This exception peppers our production catalina logs on a simple 'getParameter()' call. WARNING: Parameters: Character decoding failed. Parameter skipped. java.io.CharConversionException: EOF at org.apache.tomcat.util.buf.UDecoder.convert(UDecoder.java:82) at org.apache.tomcat.util.buf.UDecoder.convert(UDecoder.java:48) at ...

What are the principles guiding your exception handling policy?

There is a lot of relativity involved in working with exceptions. Beyond low level APIs where exceptions cover errors raised from hardware and the OS there is a shady area where the programmer decides what constitutes an exception and what is a normal condition. How do you decide when to use exceptions? Do you have a consistent policy r...

How can I get source and variable values in ruby tracebacks?

Here's the last few frames of a typical Ruby on Rails traceback: And here are the last few frames of a typical Nevow traceback in Python: It's not just the web environment either, you can make similar comparisons between ipython and irb. How can I get more of these sorts of details in Ruby? ...