Reputation: 8311
I am using a custom transformer in mule and for that I am writing custom java code which extends AbstractMessageTransformer.
I am facing a issue since in the custom java class since I need to handle FileNotFoundException and it says FileNotFoundException is not compatible with AbstractMessageTransformer.
Is there any way I can handle FileNotFoundException in custom java class that extends AbstractMessageTransformer ??
Upvotes: 0
Views: 1654
Reputation: 8311
public class MessageAttachmentTransformer extends AbstractMessageTransformer
{private List<String> filename; // file to attach
@SuppressWarnings("deprecation")
public Object transformMessage(MuleMessage message, String outputEncoding) throws TransformerException {
if (filename.isEmpty() || filename==null || filename.size()==0) **//filename is a list contains list of file path as mule attachment**
{**//If file for attachment is not there**
**//Here I want to place FileNotFoundException**
return message;} else
{ // do other thing} return message;
}
}
}
Upvotes: 0
Reputation: 3264
If what you want to re-throw the FileNotFoundException within a class extending an AbstractMessageTransformer, then you should probably wrap that exception into a TransformerException, the one thrown by the doTransform method
Your method will look like this
try{
//Your custom transformation
} catch(FileNotFoundException e){
Message msg = CoreMessages.transformFailedBeforeFilter();
throw new TransformerException(msg,this, e);
}
Upvotes: 1