commons-dev mailing list archives

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

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 
...util.Messages-class.
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 
Resources.properties file.
3. Patching the Resources.properties 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: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message