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

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

Introduction

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

Prototype

public static String getMessage(final Throwable th) 

Source Link

Document

Gets a short message summarising the exception.

Usage

From source file:com.logsniffer.web.controller.exception.ErrorResponse.java

/**
 * @param exception// w w w  .  j  ava2  s.c  o  m
 *            the exception to set
 */
public void setException(final Throwable exception) {
    setExceptionMessage(ExceptionUtils.getMessage(exception));
}

From source file:net.mindengine.galen.validation.ValidationError.java

public static ValidationError fromException(Exception e) {
    return new ValidationError().withMessage(ExceptionUtils.getMessage(e));
}

From source file:com.galenframework.reports.GalenTestAggregatedInfo.java

public String getExceptionMessage() {
    if (testInfo.getException() != null) {
        return ExceptionUtils.getMessage(testInfo.getException());
    }//from w w w .  j av a  2  s.  co m
    return null;
}

From source file:com.baasbox.commands.CollectionsResource.java

private static JsonNode dropCollection(JsonNode command) throws CommandException {
    checkPreconditions(command, true);/*from  w w  w  .  j  a v  a2 s. com*/
    String coll = extractCollectionName(command);
    try {
        CollectionService.drop(coll);
        return BooleanNode.getTrue();
    } catch (InvalidCollectionException e) {
        return BooleanNode.getFalse();
    } catch (Exception e) {
        throw new CommandExecutionException(command,
                "Error dropping collection: " + ExceptionUtils.getMessage(e));
    }
}

From source file:com.mingo.convert.DefaultConverter.java

/**
 * {@inheritDoc}/* w ww.  j  av  a2  s .  co  m*/
 */
@Override
public T convert(Class<T> type, DBObject source) {
    T result;
    source = getFirstElement(source);
    String json = JSON.serialize(source);
    try {
        result = objectMapper.readValue(json, type);
    } catch (IOException e) {
        LOGGER.error(ExceptionUtils.getMessage(e));
        throw new ConversionException(e);
    }
    return result;
}

From source file:DocumentSerializationTest.java

@Test
public void testCreateWithVersionNull() {
    running(getFakeApplication(), new Runnable() {
        public void run() {
            try {
                Result result = createDocumentWithVersionNull(getRouteAddress(collectionName));
                assertRoute(result, "testCreateWithVersionNull CREATE", Status.BAD_REQUEST, ERROR_MESSAGE,
                        true);// w w  w  .  j a  v a  2  s  .  c  o m
            } catch (Exception e) {
                assertFail(ExceptionUtils.getMessage(e));
            }
        }
    });
}

From source file:net.mindengine.blogix.web.BlogixServlet.java

@Override
protected void doGet(HttpServletRequest req, HttpServletResponse res) {
    String uri = req.getRequestURI();
    try {/*from w ww . j  a  va 2s  . co  m*/
        res.setStatus(200);
        String contentType = findContentTypeFor(uri);
        if (contentType != null) {
            res.setContentType(contentType);
        }
        blogix.processUri(uri, res.getOutputStream());
    } catch (Throwable e) {
        res.setStatus(400);
        printResponseText(res, ExceptionUtils.getMessage(e) + "\n" + ExceptionUtils.getStackTrace(e));
    }
}

From source file:com.baasbox.controllers.ScriptsAdmin.java

@BodyParser.Of(BodyParser.Json.class)
public static Result update(String name) {
    if (BaasBoxLogger.isTraceEnabled())
        BaasBoxLogger.trace("Start Method");
    Http.Request req = request();
    Result result;//from w ww . j a v  a  2s  .  c o m
    JsonNode body = req.body().asJson();

    try {

        ScriptStatus update = ScriptingService.update(name, body);
        if (update.ok) {
            result = ok(update.message);
        } else {
            result = badRequest(update.message);
        }
    } catch (ScriptEvalException e) {
        BaasBoxLogger.error("Evaluation exception: " + ExceptionUtils.getMessage(e), e);
        result = badRequest(ExceptionUtils.getMessage(e));
    } catch (ScriptException e) {
        BaasBoxLogger.error("Script exception: ", e);
        result = notFound(ExceptionUtils.getMessage(e));
    } catch (Throwable e) {
        BaasBoxLogger.error("Internal Scripts engine error", e);
        result = internalServerError(ExceptionUtils.getMessage(e));
    }
    if (BaasBoxLogger.isTraceEnabled())
        BaasBoxLogger.trace("End Method");
    return result;
}

From source file:com.mingo.parser.xml.dom.DocumentBuilderFactoryCreator.java

/**
 * Creates schema from list of {@link Source} objects.
 *
 * @param sources list of {@link Source}
 * @return immutable in-memory representation of grammar
 * @throws ParserConfigurationException {@link ParserConfigurationException}
 */// www  . ja  v a  2s  .com
private static Schema createSchema(List<Source> sources) throws ParserConfigurationException {
    Schema schema;
    try {
        schema = SCHEMA_FACTORY.newSchema(sources.toArray(new Source[0]));
    } catch (SAXException e) {
        throw new ParserConfigurationException(ExceptionUtils.getMessage(e));
    }
    return schema;
}

From source file:com.baasbox.commands.CollectionsResource.java

private static JsonNode existsCollection(JsonNode command) throws CommandException {
    //        checkPreconditions(command,false);
    String coll = extractCollectionName(command);
    try {// ww  w  .j  a  va 2s.  co m
        boolean res = CollectionService.exists(coll);
        return res ? BooleanNode.getTrue() : BooleanNode.getFalse();
    } catch (SqlInjectionException e) {
        throw new CommandExecutionException(command, ExceptionUtils.getMessage(e));
    } catch (InvalidCollectionException e) {
        throw new CommandExecutionException(command,
                "Invalid collection '" + coll + "':" + ExceptionUtils.getMessage(e));
    }
}