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 ??
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);
}
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;
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.