Hur man ignorerar undantag
Contents
[
Hide
]
Stöd för att ignorera undantag
ExceptionManager klass ger möjlighet att ignorera undantag:
Kodexempel:
Ställ in en återuppringning för att hantera undantag:
ExceptionManager.setIgnoreExceptionsHandler(new IgnoreExceptionsCallback() {
//exception path: {Module}\{Method}\{Action}\{GUID}
//example: MailMessage\Load\DecodeTnefAttachment\64149867-679e-4645-9af0-d46566cae598
public boolean invoke(AsposeException ex, String path) {
//Ignore all exceptions on MailMessage.Load
return path.equals("MailMessage\\Load");
}
});
Eller använd ett alternativ:
//Ignore all exceptions
ExceptionManager.setIgnoreAll(true);
Du kan också ställa in en återuppringning för loggning av ignorerade undantag:
ExceptionManager.setIgnoreExceptionsLogHandler(new IgnoreExceptionsLogCallback() {
public void invoke(String message) {
System.out.println("=== EXCEPTION IGNORED === " + message);
}
});
Användaren kommer att meddelas att undantaget kan ignoreras med ett felmeddelande. Till exempel:
Exceptioin message:
AsposeArgumentException: properties should not be empty.
If you want to ignore an exception and want to proceed further then you can use:
ExceptionManager.getIgnoreList().add("MailMessage\\Load\\DecodeTnefAttachment\\64149867-679e-4645-9af0-d46566cae598")
Invalid TNEF Attachment will be interpreted as regular attachment.