es.pode.buscar.negocio.federada.servicios.SrvBuscarFederadaServiceException.java Source code

Java tutorial

Introduction

Here is the source code for es.pode.buscar.negocio.federada.servicios.SrvBuscarFederadaServiceException.java

Source

// license-header java merge-point
//
// Attention: Generated code! Do not modify by hand!
// Generated by: DefaultServiceException.vsl in andromda-spring-cartridge.
//
package es.pode.buscar.negocio.federada.servicios;

import org.apache.commons.beanutils.PropertyUtils;

/**
 * The default exception thrown for unexpected errors occurring
 * within {@link es.pode.buscar.negocio.federada.servicios.SrvBuscarFederadaService}.
 */
public class SrvBuscarFederadaServiceException extends java.lang.RuntimeException {
    /**
     * The default constructor for <code>SrvBuscarFederadaServiceException</code>.
     */
    public SrvBuscarFederadaServiceException() {
    }

    /**
     * Constructs a new instance of <code>SrvBuscarFederadaServiceException</code>.
     *
     * @param throwable the parent Throwable
     */
    public SrvBuscarFederadaServiceException(Throwable throwable) {
        super(findRootCause(throwable));
    }

    /**
     * Constructs a new instance of <code>SrvBuscarFederadaServiceException</code>.
     *
     * @param message the throwable message.
     */
    public SrvBuscarFederadaServiceException(String message) {
        super(message);
    }

    /**
     * Constructs a new instance of <code>SrvBuscarFederadaServiceException</code>.
     *
     * @param message the throwable message.
     * @param throwable the parent of this Throwable.
     */
    public SrvBuscarFederadaServiceException(String message, Throwable throwable) {
        super(message, findRootCause(throwable));
    }

    /**
     * Finds the root cause of the parent exception
     * by traveling up the exception tree
     */
    private static Throwable findRootCause(Throwable th) {
        if (th != null) {
            // Reflectively get any exception causes.
            try {
                Throwable targetException = null;

                // java.lang.reflect.InvocationTargetException
                String exceptionProperty = "targetException";
                if (PropertyUtils.isReadable(th, exceptionProperty)) {
                    targetException = (Throwable) PropertyUtils.getProperty(th, exceptionProperty);
                } else {
                    exceptionProperty = "causedByException";
                    //javax.ejb.EJBException
                    if (PropertyUtils.isReadable(th, exceptionProperty)) {
                        targetException = (Throwable) PropertyUtils.getProperty(th, exceptionProperty);
                    }
                }
                if (targetException != null) {
                    th = targetException;
                }
            } catch (Exception ex) {
                // just print the exception and continue
                ex.printStackTrace();
            }

            if (th.getCause() != null) {
                th = th.getCause();
                th = findRootCause(th);
            }
        }
        return th;
    }
}