Hoe uitzonderingen te negeren
Contents
[
Hide
]
Ondersteuning voor het negeren van uitzonderingen
ExceptionManager klasse biedt de mogelijkheid om uitzonderingen te negeren:
Codevoorbeelden:
Stel een callback in om uitzonderingen af te handelen:
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");
}
});
Of gebruik een alternatief:
//Ignore all exceptions
ExceptionManager.setIgnoreAll(true);
Daarnaast kun je een callback instellen voor het loggen van genegeerde uitzonderingen:
ExceptionManager.setIgnoreExceptionsLogHandler(new IgnoreExceptionsLogCallback() {
public void invoke(String message) {
System.out.println("=== EXCEPTION IGNORED === " + message);
}
});
De gebruiker wordt geïnformeerd dat de uitzondering kan worden genegeerd via een foutmelding. Bijvoorbeeld:
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.