Example usage for org.apache.commons.lang3.exception ExceptionUtils getRootCauseMessage

List of usage examples for org.apache.commons.lang3.exception ExceptionUtils getRootCauseMessage

Introduction

In this page you can find the example usage for org.apache.commons.lang3.exception ExceptionUtils getRootCauseMessage.

Prototype

public static String getRootCauseMessage(final Throwable th) 

Source Link

Document

Gets a short message summarising the root cause exception.

Usage

From source file:com.yahoo.bullet.parsing.Error.java

/**
 * Creates an Error object with the root cause message from the given cause if available.
 *
 * @param cause A cause if available./*from   ww  w.j  av a  2 s. c o  m*/
 *
 * @return An Error representing this cause.
 */
public static Error makeError(Throwable cause) {
    String message = ExceptionUtils.getRootCauseMessage(cause);
    message = message.isEmpty() ? GENERIC_JSON_ERROR : message;
    return Error.of(message, singletonList(GENERIC_JSON_RESOLUTION));
}

From source file:com.yahoo.bullet.parsing.Error.java

/**
 * Creates an Error object with the original rule string and the root cause message from the given cause.
 *
 * @param cause A cause./*from ww  w  .  j a v a2s. c  om*/
 * @param ruleString The original rule.
 *
 * @return An Error representing this cause.
 */
public static Error makeError(RuntimeException cause, String ruleString) {
    String message = ExceptionUtils.getRootCauseMessage(cause);
    message = message.isEmpty() ? "" : message;
    return Error.of(GENERIC_JSON_ERROR + ":\n" + ruleString + "\n" + message,
            singletonList(GENERIC_JSON_RESOLUTION));
}

From source file:com.holonplatform.auth.exceptions.UnexpectedAuthenticationException.java

/**
 * Constructor//  www . j  a  v a  2 s.  c o  m
 * @param description Error message
 * @param cause Nested exception
 */
public UnexpectedAuthenticationException(String description, Throwable cause) {
    super(ErrorResponse.SERVER_ERROR,
            ExceptionUtils.getRootCauseMessage(cause) + ((description != null) ? (": " + description) : ""),
            500);
}

From source file:com.github.ibole.infrastructure.common.exception.MoreThrowables.java

/**
 * Get Root Cause Message./*from   w  w  w .  ja  v a2 s.com*/
 * @param cause Throwable
 * @return the root cause message
 */
public static String getRootCauseMessage(Throwable cause) {
    return ExceptionUtils.getRootCauseMessage(cause);
}

From source file:com.xtesy.core.internals.impl.Settings.java

/**
 * @author Wasiq B/*from ww  w. ja v  a2s  .c o  m*/
 * @since 31-May-2015 9:23:00 pm
 */
private Settings() {
    super();
    log.entry();
    try {
        addConfiguration(new SystemConfiguration());
        parseConfig();
    } catch (final ConfigurationException | FileNotFoundException e) {
        try {
            throw new FrameworkException("Load Settings", e);
        } catch (final FrameworkException e1) {
            log.catching(e1);
            log.error(ExceptionUtils.getRootCauseMessage(e1));
            log.error(ExceptionUtils.getStackTrace(e1));
        }
    } finally {
        log.exit();
    }
}

From source file:info.novatec.flyway.branching.extension.BranchingCallback.java

/**
 * Creates a new instance of {@link BranchingCallback}.
 * @param flywayInstance//from   w  ww .ja  v a  2 s.com
 *            the {@link Flyway} instance
 */
public BranchingCallback(final Flyway flywayInstance) {
    super();
    this.flyway = flywayInstance;

    try {
        this.releaseTable = initReleaseTable(flywayInstance.getDataSource().getConnection());
    } catch (SQLException e) {
        throw new FlywayException("Error getting database connection for "
                + "initializing release table. Reason: " + ExceptionUtils.getRootCauseMessage(e));
    }

    try {
        switchLocations(getCurrentRelease(flywayInstance.getDataSource().getConnection()));
    } catch (SQLException e) {
        throw new FlywayException("Error getting database connection for getting current "
                + "release from release table. Reason: " + ExceptionUtils.getRootCauseMessage(e));
    }
}

From source file:hoot.services.log4j2.BrokenPipeFilter.java

private Result filter(Throwable t) {
    if (ExceptionUtils.getRootCauseMessage(t).contains("SocketException: Broken pipe")
            || ExceptionUtils.getRootCauseMessage(t).contains("IOException: Broken pipe")) {
        return Result.DENY;
    } else {/*from w  w w  . j  av  a 2s .c o  m*/
        return Result.NEUTRAL;
    }
}

From source file:fi.helsinki.opintoni.exception.GlobalExceptionHandlers.java

@ExceptionHandler(value = Exception.class)
public ResponseEntity<CommonError> handleException(Exception e) throws Exception {
    // Only log a brief info message on broken pipes
    if (StringUtils.containsIgnoreCase(ExceptionUtils.getRootCauseMessage(e), "Broken pipe")) {
        LOGGER.info("Broken pipe occurred");
        return null;
    }//from   w  w  w  .  j av  a 2s  .c o m

    // If the exception is annotated with @ResponseStatus, rethrow it for other handlers
    if (AnnotationUtils.findAnnotation(e.getClass(), ResponseStatus.class) != null) {
        throw e;
    }

    LOGGER.error("Caught exception", e);

    return new ResponseEntity<>(new CommonError("Something went wrong"), HttpStatus.INTERNAL_SERVER_ERROR);
}

From source file:br.com.modoagil.asr.rest.security.UserWebService.java

/**
 * Busca por usurio pelo email fornecido
 *
 * @param email/* w  w w. j ava2s . co m*/
 *            email a ser consultado
 * @return {@link Usuario}
 */
@RequestMapping(value = WebServicesURL.URL_USUARIO_FIND_EMAIL + "/{email}", method = { GET,
        POST }, produces = APPLICATION_JSON)
public Response<User> findUsuarioByEmail(@PathVariable("email") final String email) {
    Response<User> response;
    getLogger().debug("buscando usurio pelo email '" + email + "'");
    try {
        final User usuario = getRepository().findByEmailIgnoreCase(email);
        if (usuario != null) {
            response = new ResponseBuilder<User>().success(true).data(usuario)
                    .message(String.format(ResponseMessages.FIND_MESSAGE, usuario.getId()))
                    .status(HttpStatus.OK).build();
            getLogger().debug("sucesso ao buscar usurio pelo email '" + email + "'");
        } else {
            response = new ResponseBuilder<User>().success(true)
                    .message(String.format("Usurio com email %s no foi encontrado", email))
                    .status(HttpStatus.OK).build();
            getLogger().debug("no foi encontrado usurio com email '" + email + "'");
        }
    } catch (final Exception e) {
        final String message = ExceptionUtils.getRootCauseMessage(e);
        response = new ResponseBuilder<User>().success(false).message(message).status(HttpStatus.BAD_REQUEST)
                .build();
        getLogger().error("erro ao buscar usurio pelo email '" + email + "'", e);
    }
    return response;
}

From source file:com.xpn.xwiki.internal.skin.EnvironmentSkin.java

public Configuration getProperties() {
    if (this.properties == null) {
        URL url = this.environment.getResource(getSkinFolder() + "skin.properties");
        if (url != null) {
            try {
                this.properties = new PropertiesConfiguration(url);
            } catch (ConfigurationException e) {
                LOGGER.error("Failed to load skin [{}] properties file ([])", this.id, url,
                        ExceptionUtils.getRootCauseMessage(e));

                this.properties = new BaseConfiguration();
            }//from   w  w w.  j  a va  2s .  c  o m
        } else {
            LOGGER.debug("No properties found for skin [{}]", this.id);

            this.properties = new BaseConfiguration();
        }
    }

    return this.properties;
}