Jak ignorować wyjątki

Obsługa ignorowania wyjątków

ExceptionManager klasa zapewnia możliwość ignorowania wyjątków:

Przykłady kodu:

Ustaw wywołanie zwrotne do obsługi wyjątków:

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");
    }
});

Lub użyj alternatywy:

//Ignore all exceptions
ExceptionManager.setIgnoreAll(true);

Ponadto możesz ustawić wywołanie zwrotne dla zignorowanego logu wyjątków:

ExceptionManager.setIgnoreExceptionsLogHandler(new IgnoreExceptionsLogCallback() {
    public void invoke(String message) {
        System.out.println("=== EXCEPTION IGNORED === " + message);
    }
});

Użytkownik zostanie poinformowany, że wyjątek można zignorować komunikatem o błędzie. Na przykład:

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.