exception

StackOverflowException in .NET

After hitting a few StackOverflowExceptions in .NET I noticed they completely bypass the unhandled exception handlers that .NET offers (Application.ThreadException / AppDomain.UnhandledException). This is very disturbing since we have critical cleanup code in those exception handlers. Is there any way to overcome this? ...

Not getting emails from ExceptionNotifier

I followed this tutorial on configuring the Rails plugin ExceptionNotifier. I know that I have ActionMailer configured correctly because I am getting mail from other forms. I even have local_addresses.clear set so that it should be delivering mail no matter what. I am using Apache with a mongrel_cluster running in the backend. What am...

How can I test for an expected exception with a specific exception message from a resource file in Visual Studio Test?

Visual Studio Test can check for expected exceptions using the ExpectedException attribute. You can pass in an exception like this: [TestMethod] [ExpectedException(typeof(CriticalException))] public void GetOrganisation_MultipleOrganisations_ThrowsException() You can also check for the message contained within the ExpectedException li...

Why Re-throw Exceptions?

I've seen the following code many times: try { ... // some code } catch (Exception ex) { ... // Do something throw new CustomException(ex); // or // throw; // or // throw ex; } Can you please explain the purpose of re-throwing an exception? Is it following a pattern/best practice in exception handling? (I...

Catching base Exception class in .NET

Hello, I keep hearing that catch (Exception ex) Is bad practise, however, I often use it in event handlers where an operation may for example go to network, allowing the possibility of many different types of failure. In this case, I catch all exceptions and display the error message to the user in a message box. Is this considered...

How do you fix "Too many open files" problem in Hudson?

We use Hudson as a continuous integration system to execute automated builds (nightly and based on CVS polling) of a lot of our projects. Some projects poll CVS every 15 minutes, some others poll every 5 minutes and some poll every hour. Every few weeks we'll get a build that fails with the following output: FATAL: java.io.IOException...

Detecting what the target object is when NullReferenceException is thrown.

I'm sure we all have received the wonderfully vague "Object reference not set to instance of an Object" exception at some time or another. Identifying the object that is the problem is often a tedious task of setting breakpoints and inspecting all members in each statement. Does anyone have any tricks to easily and efficiently identif...

Visual Studio: How to break on handled exceptions?

i would like Visual Studio to break when a handled exception happens (i.e. i don't just want to see a "First chance" message, i want to debug the actual exception). e.g. i want the debugger to break at the exception: try { System.IO.File.Delete(someFilename); } catch (Exception) { //we really don't care at runtime if the file cou...

design by contract tests by assert or by exception?

When programming by contract a function or method first checks whether its preconditions are fulfilled, before starting to work on its responsibilities, right? The two most prominent ways to do these checks are by assert and by exception. assert fails only in debug mode. To make sure it is crucial to (unit) test all separate contract ...

Best practice for translating exceptions in C++/CLI wrapper class

I am writing a .NET wrapper class for an existing native class which throws exceptions. What are the best practices for translating between native C++ exceptions and Managed exceptions? Catch and re-throw on a one-to-one basis (e.g. std::invalid_argument -> System.System.ArgumentException)? Is there a mapping already drawn up somewhere? ...

Getting Socket closed error when a remoting exception is thrown on the server

Hello, I have an app that is built using .Net remoting. When authenticating, If there is an error, I threw an exception on the server. The exception is serializable. But when the exception is thrown on the server, Sometimes I see an error on the client side that says "An established connection was aborted by the software in your host ma...

Catching line numbers in ruby exceptions.

Consider the following ruby code test.rb: begin puts thisFunctionDoesNotExist x = 1+1 rescue Exception => e p e end For debugging purposes, I would like the rescue block to know that the error occurred in line 4 of this file. Is there a clean way of doing that? ...

I'm getting a strange unhandled exception from my asp.net application - Validation of viewstate MAC failed

I don't know if anyone has seen this issue before but I'm just stumped. Here's the unhandled exception message that my error page is capturing. Error Message: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validatio...

What Exception should be thrown when an ADO.NET query cannot retrieve the requested data?

In an attempt to add some parameter validation and correct usage semantics to our application, we are trying to add correct exception handling to our .NET applications. My question is this: When throwing exceptions in ADO.NET if a particular query returns no data or the data could not be found, what type of exception should I use? Psue...

throw exception from a JSP

Hi, Is it possible to throw an exception in a JSP without using scriptlet code? Cheers, Don ...

ClickOnce app not working with Office 2007

I am a developer for a .net application that uses ClickOnce for deployment. I have deployed it over 60 times and computers have not had any issues downloading the latest release. However, when I deployed this morning, the following error occurs when computers with Office 2007 installed tries to start the application: Unable to instal...

Invalid group name: Group names must begin with a word character

I received the following exception when I was using the Regex class with the regular expression: (?'named a'asdf) System.ArgumentException: parsing \"(?'named a'asdf)\" - Invalid group name: Group names must begin with a word character. What is the problem with my regular expression? ...

Delaying an exception

I have a method that periodically (e.g. once in every 10 secs) try to connect to a server and read some data from it. The server might not be available all the time. If the server is not available the method throws an exception. What would be the best way to implement a wrapper method that doesn't throw an exception except if the server...

Why are Exceptions not Checked in .NET?

I know Googling I can find an appropriate answer, but I prefer listening to your personal (and maybe technical) opinions. What is the main reason of the difference between Java and C# in throwing exceptions? In Java the signature of a method that throws an exception has to use the "throws" keyword, while in C# you don't know in compilati...

Interrupts and exceptions

I've seen several question on here about exceptions, and some of them hint at interrupts as exceptions, but none make the connection clear. What is an interrupt? What is an exception? (please explain what exceptions are for each language you know, as there are some differences) When is an exception an interrupt and vice-versa? ...