Hello there,
I'm using camel-core version 2.9.1.

I have an application that uses the File2 Camel Component. In cases of
write failures, my application intends to take the system error codes (
http://docs.oracle.com/cd/E17952_01/refman-5.0-en/operating-system-error-codes.html),
and map it to an application level error code and send it to a client of my
application in a JMS response message.

I initially thought that the system error code would be reflected in the
facade exception GenericFileOperationFailedException. This doesn't appear
to be the case. Is this assertion correct?

So for example, if a directory doesn't have write permissions :

                from("file:/tmp/data?noop=true").process(new Processor() {
                    public void process(Exchange exchange) throws Exception
{
                        System.out.println("Shall attempt to write a sample
file to a directory with no write permission");
                    }
                }).to("file:/tmp/no_write_permission");

I have to dig into the GenericFileOperationFailedException to get the
FileNotFoundException, look for "Permission denied" in the
FileNotFoundException message, and if I find a match, then map to my
application-level error code. Somewhere in the exception chain the error
code provided by the OS is lost.

Any advice on how to best use GenericFileOperationFailedException in this
case?
As a user it would be more preferable if I could use the getCode() on the
GenericFileOperationFailedException to reliably get the system error code,
when a system error is generated.
BRs //John.

Reply via email to