exception-handling

Is object oriented exception handling in Perl worth it?

I recently read "Object Oriented Exception Handling in Perl" Perl.com article. Is there any point to use exceptions in Perl? ...

How do I gracefully test for overflow situations in C#?

Update: I'm going to leave it as is: The performance hit of a exception (very rare) is better than the probably performance hit for checking on each operation (common) I'm trying to support an "EstimatedRowCount" that in one case would be the product of two sub-cursors that are joined together: estimatedRowCount = left.EstimatedRowCo...

Throwing exceptions in Java

Hello, I have a question about throwing exceptions in Java, a kind of misunderstanding from my side, as it seems, which I would like to clarify for myself. I have been reading that the two basic ways of handling exception code are: 1.) throwing an exception in a try-block with "throw new ...", and catching it immediately in a catch-bl...

How can I force unhandled exceptions in a WCF thread to crash the process?

So here's the scenario: I have a WCF service that has a bunch of FaultContracts defined per operation. I would like to arrange it such that if an unhandled exception is thrown in a WCF service thread that does not match a valid FaultContract, it takes down the entire process rather than just the thread. (The reason being that I would ...

c# "finally" block that only runs on exceptions.

Edit: I have looked at the answers code: NONE of them do what I want (I've checked). It would seem that there is no way to do what I want in native c#. I guess that's not a disaster just a shame given that .NET does support it (see accepted answer). Thanks all. I have c# code (part of a test framework that will never be run except un...

Should a business rule violation throw an exception?

Should a business rule violation throw an exception? ...

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...

Doubt in exception handling and finally block in java

Can you tell the idea of how to doing it? Code : public void main(String[] args) { try { //Some Exception throws here } catch(SomeException se) { se.printStackTrace(); } finally { try { //SomeException1 throws here } catch(SomeException1 se1) { se.prin...

Facing problem in log4j error log and exception handling

Hi : I have used log4j for looging error log using FileAppender. The problem is its logging the same error two times in a log file when the below situation Case1: Class1 : public void func(){ try{ new Class2.prop() }catch(IOException ioe){ logger.log(2,ioe); } } Class2 : public void prop(){ try{ ...

What can cause Outlook to change a COM-addin's LoadBehavior to 2 - other than unhandled exceptions?

For some weeks now we have been fighting with an issue where at a small number of customers our Outlook addin gets unloaded and disabled for yet undetermined reasons. By "disabled" I mean that Outlook changes the following registry value from 3 to 2 which in effect means that the addin will not be loaded on next startup: HKEY_LOCAL_MACH...

What's the essential difference between the two HandleException() methods of Exception Handling Application Block (Ent Lib 4.1)

In the most recent version (4.1, released October 2008) of The Microsoft Enterprise Library's Exception Handling Application Block, there are two HandleException() method signatures, and I am a bit lost on the intent for these, especially since neither the documentation, intellisense, nor the QuickStart apps intimate any meaningful diffe...

Why use finally in C#?

Whatever is inside finally blocks is executed (almost) always, so what's the difference between enclosing code into it or leaving it unclosed? ...

How can I switch off exception handling in MSVC?

Does anybody know how to switch off exception handling option in MSVC? I tried to set the option 'Enable C++ exceptions' to 'NO' and I got warning: warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc I would like to switch off the exception handler, too, but I don't know how. In my application...

Can I disable exceptions in STL?

Hello, I want to disable exceptions in my C++ aplication, compiled under MSVC. I hve switched the option Enable C++ exceptions to NO, but I get warnings telling me to use the option /Ehsc, which I dont want to. I do not have try/catch blocks in my code, but I use STL. I have found that using macro definition _HAS_EXCEPTIONS=0 should...

How to throw good exceptions?

I heard you should never throw a string because there is a lack of information and you'll catch exceptions you dont expect to catch. What are good practice for throwing exceptions? do you inherit a base exception class? Do you have many exceptions or few? do you do MyExceptionClass& or const MyExceptionClass& ? etc. Also i know exceptio...

Is it bad practice for an object to catch its own exception and store the message in a property?

Let's say I have a list of objects of the same type. I want to iterate over that list of objects and execute a "dangerous" method on each of them. If an exception occurs in that method, is it bad practice to have the method itself catch the exception and set an error property on the object? Here's a quick example where the Start() m...

Exception handling in ASP.NET Webforms

What is the preferred method for handling exceptions in ASP.NET Webforms? You have the Page_Error method that you add (I think) at web.config level, and the entire site gets redirected there when an error occurs. Does that mean you shouldn't use try-catch anywhere in a webforms application? (Assuming you don't want to hide any errors) ...

Determining exception type after the exception is caught?

Is there a way to determine the exception type even know you caught the exception with a catch all? Example: try { SomeBigFunction(); } catch(...) { //Determine exception type here } ...

is there a pythonic way to try something up to a maximum number of times?

I have a python script which is querying a MySQL server on a shared linux host. For some reason, queries to MySQL often return a "server has gone away" error: _mysql_exceptions.OperationalError: (2006, 'MySQL server has gone away') If you try the query again immediately afterwards, it usually succeeds. So, I'd like to know if there's ...

AJAX Update panel swallows exceptions and its strange behaviour

Hi all I've got just caught with strange behavior of AJAX update panel. The first think made me embarrassed is that I have noticed that when I throw exception during async postback, it is swallowed by enviroment. Since it's first time when I faced to such issue, I started to make experiments - trying either to throw different types o...