The cause of an IOException

In Java on 2007-05-17 by Jukka Zitting

I just had to follow a stack trace through a complex codebase with multiple layers. The exception chaining mechanism introduced in Java 1.4 made the task easy up to the point where the last exception in the chain was an IOException thrown by code like this:

try {
} catch (Exception e) {
    throw new IOException("...");

What a dead end! The problem is that the IOException constructors that allow exception chaining were only added in Java 6. Here’s a workaround that would have saved me a lot of extra effort:

try {
} catch (Exception e) {
    IOException ioe = new IOException("...");
    throw ioe;

One Response to “The cause of an IOException”

  1. Java exceptions are a PITA to debug, this bug[1] “Exception messages are often uninformative” has been open since 2001…


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: