* @return an exception instance identified by exceptionId
*/
public TuboException getException(String exceptionId, String message, Throwable cause) {
//
// get bean (TuboException) instance using default constructor
TuboException exception = null;
try {
exception = (TuboException)beanFactory.getBean(exceptionId);
} catch (BeansException e) {
log.error("Error when obtains bean (exception) from beanFactory", e) ;
//
// if there is an error when create bean, then use super default
exception = super.getException(exceptionId, message,cause);
//
// return
return exception;
}
//
// then now if message or cause are not null then I need recreate exception
try {
if (message!=null && cause!=null) {
exception = (TuboException)exception.getClass().getConstructor(new Class[] {String.class,Throwable.class}).newInstance(new Object[] {message,cause});
}
else
if (message!=null && cause==null) {
exception = (TuboException)exception.getClass().getConstructor(new Class[] {String.class}).newInstance(new Object[] {message});
}
else
if (message==null && cause!=null) {
exception = (TuboException)exception.getClass().getConstructor(new Class[] {Throwable.class}).newInstance(new Object[] {cause});
}
} catch (InstantiationException e) {
log.error("Error, Exception can't be instanciated", e);
} catch (IllegalAccessException e) {
log.error("Error, accesing Exception", e);