exception-handling

what happens when two exceptions occur?

what will the program behave when they have two exceptions. And none of them have been caught yet. what type of handler will be called . lets say both the exceptions were of different type. i apologize if i am not clear but i feel i have made myself clear enough. thank you!!! what if the try block throws an exception and try block is ex...

How do I find where an exception was thrown in C++?

I have a program that throws an uncaught exception somewhere. All I get is a report of an exception being thrown, and no information as to where it was thrown. It seems illogical for a program compiled to contain debug symbols not to notify me of where in my code an exception was generated. Is there any way to tell where my exceptions ...

Handling multiple exceptions

Hi there, I have written a class which loads configuration objects of my application and keeps track of them so that I can easily write out changes or reload the whole configuration at once with a single method call. However, each configuration object might potentially throw an exception when doing IO, yet I do not want those errors to c...

What should be the appropriate name of a log file

I want to log my exceptions in a file. What will be the name of the file? Error-ddmmyyyy.log Log-ddmmyyyy.err Log-ddmmyyyy.txt or anything else? ...

NServiceBus exception handling and message retry mechanism

We are planning to use NServiceBus in our application for dispatching messages. In our case each message has timeToLive property, defining period of time, in which this message should be processed. For the case if message handling was unsuccessful in first attempt, our plan is to move it to specific retry storage (retry queue) and than ...

How can I print the argument value that caused Exception in Java?

I am writing a parser for csv-files, and sometimes I get NumberFormatException. Is there an easy way to print the argument value that caused the exception? For the moment do I have many try-catch blocks that look like this: String ean; String price; try { builder.ean(Long.parseLong(ean)); } catch (NumberFormatException e) { Sy...

Generating heap dump from Java code

Hi, I'm trying to programm a self destruction logic. I've already created a global ExceptionHandler which will be processed in some cases. I want to collect some system information before the destruction. One information should be the current heap dump. I found The following page http://blogs.sun.com/sundararajan/entry/programmatically_...

C#: When should I use TryParse?

I understand it doesn't throw an Exception and because of that it might be sightly faster, but also, you're most likely using it to convert input to data you can use, so I don't think it's used so often to make that much of difference in terms of performance. Anyway, the examples I saw are all along the lines of an if/else block with Tr...

Is it possible anyhow to raise system exception on catching exception manually?

I am writing a stored procedure where i m using try catch block. Now i have a unique column in a table. When i try to insert duplicate value it throws exception with exception no 2627. I want this to be done like this if (exists(select * from tblABC where col1='value')=true) raiseError(2627)--raise system error that would have thrown...

Can I write my owm template in TextFormatter used in Logging Application Block in C#?

Can I write my owm template in TextFormatter used in Logging Application Block in C#? Basically I want to write my exception log in atext file and in specific format where I want to include database information and software version. ...

Display Exceptions in JSF | JSP Page

Hi, i'am using JSF and Spring in a web application. If the Spring Controller throws exceptions i map them to special views. Now I'd like to catch all exceptions which are thrown out of scope of the Spring Context. In my web.xml i've defined an error page. <!-- handle uncaught exceptions --> <error-page> <exception-type>java.lang....

Should I create private static final String = "Some exception message" or leave it inside the code?

Should I create private static final String = "Some exception message" or leave it inside the code? Is there any performance issues? I have a lot of exception cases. Texts are mostly different in any particular case. Wary about performance and memory issues. Internationalization is quite possible in future recs. ...

How can I set up .NET UnhandledException handling in a Windows service?

protected override void OnStart(string[] args) { AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); Thread.Sleep(10000); throw new Exception(); } void CurrentDomain_UnhandledException(object sender, UnhandledExcep...

How to ignore exception with HandleErrorAttribute OnException event

Hi, I want to manage all of my exceptions in some HandleErrorAttribute class. but for some specific exceptions types i want to ignore or cancel the exceptions handeling and just continue with the parent request.. thanks ...

MS Exam 70-536 - How to throw and handle exception from thread?

Hello! In MS Exam 70-536 .Net Foundation, Chapter 7 "Threading" in Lesson 1 Creating Threads there is a text: Be aware that because the WorkWithParameter method takes an object, Thread.Start could be called with any object instead of the string it expects. Being careful in choosing your starting method for a thread to deal with...

Is re-throwing an exception legal in a nested 'try'?

Is the following well-defined in C++, or not? I am forced to 'convert' exceptions to return codes (the API in question is used by many C users, so I need to make sure all C++ exceptions are caught & handled before control is returned to the caller). enum ErrorCode {…}; ErrorCode dispatcher() { try { throw; } catch (std::b...

Handling exceptions, is this a good way?

We're struggling with a policy to correctly handle exceptions in our application. Here's our goals for it (summarized): Handle only specific exceptions. Handle only exceptions that you can correct Log only once. We've come out with a solution that involves a generic Application Specific Exception and works like this in a piece of cod...

Checked equivalent to IllegalArgumentException?

I have a method that takes an enum as a parameter and returns some information dependent on that parameter. However, that enum contains some values which should not be handled, and should raise an error condition. Currently the method throws an IllegalArgumentException but I would like this to be a checked exception to force callers to...

Is checking for exceptions in code or using try-catch a better practice in Java?

I had someone mention to me that catching all exceptions is not necessarily good practice (for example, NullPointerException). I am looking for an explanation of when this is a good thing, when it is not, and why it is as such :D Thanks!! badPanda ...

Delphi Exception Handling - How to clean up properly?

I'm looking at some code in an application of ours and came across something a little odd from what I normally do. With exception handling and cleanup, we (as well as many other programmers out there, I'm sure) use a Try/Finally block embedded with a Try/Except block. Now I'm used to the Try/Except inside the Try/Finally like so: Try ...