commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Falk Tröger <>
Subject [vfs] discussion: custom FileSystemException messages
Date Wed, 08 Mar 2006 14:46:33 GMT

it´s nearly impossible to throw a custom FileSystemException (custom 
message) in an external FileSystemProvider:

1. FileSystemException-class is declared final!
2. FileSystemException got no constructor that accepts a custom message.
3. The exception messages are resolved via static method calls to the 
4. Messages does a 
ResourceBundle.getBundle("org.apache.commons.vfs.Resources") to get the 
ResourceBundle - there are no fallbacks.

So adding a custom message can (hardly) be done through:

1. Using the constructor FileSystemException(Throwable) and pass a dummy 
exception instance containing the custom message (-> actually the best 
work around)
2. Create a ResourceBundle-class org.apache.commons.vfs.Resources that 
handles unknown resource keys and does a fallback to the vfs´s file.
3. Patching the file inside the vfs-jar.
4. Accessing the message-field of a FileSystemException instance using 
some evil reflection hacking  ;-)

Possible solution:

1. Remove final state FileSystemException (Why not throw (and catch) 
custom FileSystemExceptions?)
2. Add a constructor FileSystemException(String msg, Throwable cause, 
boolean localize) ( <- does not collide with other constructors )

What do you think about this?

Thanks a lot.

Falk Tröger

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message