camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: File2 Component's GenericFileOperationFailedException and its code attribute
Date Tue, 11 Sep 2012 10:26:35 GMT

The API does *not* give back an codes etc. Its just
true|false, or IOException.

The getCode method is for other kind of file systems (components) that
offers that.
For example the FTP components.

On Tue, Sep 11, 2012 at 12:22 PM, John Lee <> wrote:
> 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 (
> 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.

Claus Ibsen
Twitter: davsclaus, fusenews
Author of Camel in Action:

View raw message