Come ignorare le eccezioni

Supporto per ignorare le eccezioni

ExceptionManager la classe fornisce la capacità di ignorare le eccezioni:

Esempi di codice:

Imposta un callback per gestire le eccezioni:

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

Oppure usa un’alternativa:

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

Inoltre, è possibile impostare un callback per il log delle eccezioni ignorate:

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

All’utente verrà notificato che l’eccezione può essere ignorata tramite un messaggio di errore. Per esempio:

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.