अपवादों को कैसे अनदेखा करें

अपवाद अनदेखा समर्थन

ExceptionManager क्लास अपवादों को अनदेखा करने की क्षमता प्रदान करती है:

कोड उदाहरण:

अपवादों को संभालने के लिए एक कॉलबैक सेट करें:

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

या एक वैकल्पिक उपयोग करें:

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

आप अनदेखा किए गए अपवाद लॉग के लिए एक कॉलबैक भी सेट कर सकते हैं:

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

उपयोगकर्ता को सूचित किया जाएगा कि अपवाद को एक त्रुटि संदेश द्वारा अनदेखा किया जा सकता है। उदाहरण के लिए:

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.