exception

ClosedByInterruptException not thrown

The JDK docs say, that if a thread is interrupted that currently blocks in an io operation of an InterruptibleChannel, the channel is closed and a ClosedByInterruptException is thrown. However, i get a different behaviour when using a FileChannel: public class Main implements Runnable { public static void main(String[] args) throws Exc...

Should a Perl module raise exceptions (die/croak)?

When writing a Perl module, is it a good practice to use croak/die inside the module? After all, if the caller doesn't use an eval block, the module might crash the program calling it. What is the best practice in these cases? ...

Catching some exceptions but ignoring others - why doesn't this work?

I have something similar to this. void func() { try { //socket disconnects in middle of ..parsing packet.. } catch(Exception ex) { if(!ex.getMessage().toString().equals("timeout") || !ex.getMessage().toString().equals("Connection reset")) { debug("Exception (run): " + ex.getMessage()); ex.printStackTrace(); } } ...

Hibernate and NonUniqueObjectException

Hi all, i have an entity that contains two other entities with @ManyToOne relationship. @Entity public class A extends Serializable{ @Id @GeneratedValue(strategy=GenerationType.IDENTITY) private Long id; @ManyToOne @Cascade(CascadeType.SAVE_UPDATE) private B b; @ManyToOne @Cascade(CascadeType.SAVE_UPDA...

Should exceptions be chained in C++?

Hello, This may have been asked previously, but I search the stack and couldn't find any which really hit upon this. I just finished work on a C++-program where I've implemented my own exceptions (although derived from std::exception). The practice I've applied when one exception causes a chain reaction, propagating the error upwards a...

manageable way to handle exceptions in java

I am trying to come up with a manageable way to handle exceptions in a DAO. Typically a method in my DAO looks like this: public ArrayList fetchColors (String id) { //call iBatis SqlMapClient //put results in a list //return list } If an error happens in the above code then everything is written to server.log and on the f...

Catch a run-time exception

Following fails to catch a exception int *i; //intentionally uninitialized try { *i = 6; } catch (const runtime_error e) { cout << "caught!" << endl; } is it actually catching a runtime error or an exception? ...

android code to fetch data from database

ParsedNotificationDataSet result = new ParsedNotificationDataSet(); Cursor c = db.rawQuery("select * from notificationtable", null); if (c.getCount() > 0) { c.moveToFirst(); do { result.setclassurl(c.getString(c.getColumnIndex("Id"))); result.settype(c.getString(c....

Argument Exceptions should be Unit Tested?

I know this question is pretty similar to others that have been posted before but I would like to discuss this topic in a proper way. Do you think that the "obvious" exception should be unit tested? With obvious exception I mean for example exceptions due to null arguments or empty strings or negative numbers in situations where we the...

Application.ThreadException for ALL exception? Not just un-trapped ones?

I'm trying to create a top level exception capture for a debug version of some real-time data capture software and was wondering if there was a top-level exception handler similar to Application.ThreadException that captures ALL exceptions, not just unhandled/trapped ones. Thanks in advance ...

Subclassing exceptions

We all agree that using different exception types for different tasks is the way to go. But then, we end up with creating ghost files like this: /** * Zend Framework * * LICENSE * * This source file is subject to the new BSD license that is bundled * with this package in the file LICENSE.txt. * It is also available through the w...

Guidelines on Exception propagation (in Java)

Are there any guidelines on exception propagation in Java? When do you add an exception to the method signature? For example: if an exception is only thrown when an essential program resource is missing, and can only be handled at the top level, do I propagate it through all methods using this exception through all the methods using the...

How to detect if a program is executing under a thrown exception at runtime?

Can I detect at runtime inside method Helper() that the program execution is the result of a thrown exception? Note, my goal is to avoid extending method Helper() to take an exception object as a input pararmeter. public void MyFunc1() { try { // some code here that eventaully throws an exception } catch( Exception ex ) ...

JSON.Net throwing System.Security.VerificationException: Operation could destabilize the runtime.

I have a web application which uses JSON.Net to write out an array of data from a .Net Array(). When run in the VS2010 environment, it works fine. When run under IIS6 and .Net 3.5, it works fine. When run under IIS7 or 7.5 and .Net 3.5 when .Net 4.0 is installed (but the app pool and site is set to use v2 runtime), it fails with the e...

NoClassDef for JDBCExceptionHelper in JBoss 5, even if the class DOES exist in lib. Why??

I got this exception while calling a named HQL query in an EJB. I'm quite puzzled though because the app. functions fine with named queries and all. Only when it throws some exception, it can't find the JDBCExceptionHelper. javax.ejb.EJBTransactionRolledbackException: Unexpected Error java.lang.NoClassDefFoundError: org/hibernate/exce...

Problems deploying Spring 2 aplication in Apache Tomcat 6

I'm trying to starting up with a Spring 2 + Struts 2 + Hibernate 3 arquitecture project, but I get an exception when deploy it in Apache Tomcat 6.0 within Eclipse (Helios version). Tomcat's exception on start: GRAVE: Error configurando escuchador de aplicación de clase org.springframework.web.context.ContextLoaderListener java.lang.Cla...

Android Broadcast Receiver Error: Class not found exception

I have a Broadcast receiver setup so that a pop-up message is displayed to the user after each upgrade of my app, or if this is the first time the package is installed. I tested this on my Droid running Android 2.2 both as a fresh install and after upgrading my app, as well in the Emulator running 1.5 and 1.6, and I see everything run fi...

wcf and unstable connection

Hi All, I have a wcf service hosted in iis. The endpoint uses wsHttpBinding. I have a lot of clients that are using the service. The internet connection is unstable. The clients uses the service to insert data in db. What is the best practice of exception handling in the client. Is it good choise to use the using statemen and initi...

Actionscript 3 top-level exception handling

Is it possible to catch ALL exceptions at some top-level in Actionscript 3? If so, how? ...

Will C++ throw with no arguments work inside another frame to rethrow an exception?

If I have a code like the following: try { doSomething(); } catch (...) { noteError(); } void noteError() { try { throw; } catch (std::exception &err) { std::cerr << "Note known error here: " << err.what(); } catch (...) { std::cerr << "Note unknown error here."; } throw; } Will the original exceptions get t...