
com.att.aft.dme2.util.DME2ExceptionHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dme2-api Show documentation
Show all versions of dme2-api Show documentation
Direct Messaging Engine dme2-api
The newest version!
package com.att.aft.dme2.util;
import com.att.aft.dme2.api.DME2Exception;
import com.att.aft.dme2.logging.Logger;
import com.att.aft.dme2.logging.LoggerFactory;
public class DME2ExceptionHandler {
private static final Logger logger = LoggerFactory.getLogger(DME2ExceptionHandler.class);
/**
* Handles an Exception in the sense that it checks if the input Exception
* is an unchecked Exception. If it is, then a DME2Exception is created then
* the unchecked Exception is wrapped within the DME2Exception and returned.
* If the input Exception is of type DME2Exception, then it is just
* returned.
*/
public static DME2Exception handleException(Exception e, String uriString) {
DME2Exception ex = null;
if (e instanceof DME2Exception) {
return (DME2Exception) e;
} else {
ErrorContext ec = new ErrorContext();
ec.add("URI", uriString);
ec.add("Exception", e.toString() );
ec.add( "ExceptionMessage", e.getMessage() );
ex = new DME2Exception("AFT-DME2-9000", ec, e);
logger.error(null, "handleException", DME2Constants.EXCEPTION_HANDLER_MSG, ec, ex);
}
return ex;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy