Example usage for java.lang Throwable getMessage

List of usage examples for java.lang Throwable getMessage

Introduction

In this page you can find the example usage for java.lang Throwable getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:opensnap.web.AbstractStompController.java

@MessageExceptionHandler
@SendToUser(Queue.ERROR)
public String handleException(Throwable exception) {
    return exception.getMessage();
}

From source file:com.evolveum.midpoint.test.IntegrationTestTools.java

public static void assertNotInMessageRecursive(Throwable e, String substring) {
    assert !e.getMessage().contains(substring) : "The substring '" + substring
            + "' was found in the message of exception " + e + ": " + e.getMessage();
    if (e.getCause() != null) {
        assertNotInMessageRecursive(e.getCause(), substring);
    }/*from w ww . j a v a 2  s.c  om*/
}

From source file:net.sf.jabref.exporter.FileActions.java

/**
 * Saves the database to file. Two boolean values indicate whether only
 * entries with a nonzero Globals.SEARCH value and only entries with a
 * nonzero Globals.GROUPSEARCH value should be saved. This can be used to
 * let the user save only the results of a search. False and false means all
 * entries are saved./*  www .j  a  v  a2s.c o  m*/
 */
public static SaveSession saveDatabase(BibDatabase database, MetaData metaData, File file,
        JabRefPreferences prefs, boolean checkSearch, boolean checkGroup, Charset encoding,
        boolean suppressBackup) throws SaveException {

    boolean backup = prefs.getBoolean(JabRefPreferences.BACKUP);
    if (suppressBackup) {
        backup = false;
    }

    SaveSession session;
    BibEntry exceptionCause = null;
    try {
        session = new SaveSession(file, encoding, backup);
    } catch (Throwable e) {
        if (encoding != null) {
            LOGGER.error("Error from encoding: '" + encoding.displayName(), e);
        }
        // we must catch all exceptions to be able notify users that
        // saving failed, no matter what the reason was
        // (and they won't just quit JabRef thinking
        // everything worked and loosing data)
        throw new SaveException(e.getMessage(), e.getLocalizedMessage());
    }

    Map<String, EntryType> types = new TreeMap<>();

    // Get our data stream. This stream writes only to a temporary file,
    // until committed.
    try (VerifyingWriter writer = session.getWriter()) {

        // Write signature.
        FileActions.writeBibFileHeader(writer, encoding);

        // Write preamble if there is one.
        FileActions.writePreamble(writer, database.getPreamble());

        // Write strings if there are any.
        FileActions.writeStrings(writer, database);

        // Write database entries. Take care, using CrossRefEntry-
        // Comparator, that referred entries occur after referring
        // ones. Apart from crossref requirements, entries will be
        // sorted as they appear on the screen.
        List<BibEntry> sorter = FileActions.getSortedEntries(database, metaData, null, true);

        BibEntryWriter bibtexEntryWriter = new BibEntryWriter(new LatexFieldFormatter(), true);

        for (BibEntry entry : sorter) {
            exceptionCause = entry;

            // Check if we must write the type definition for this
            // entry, as well. Our criterion is that all non-standard
            // types (*not* customized standard types) must be written.
            EntryType entryType = entry.getType();

            if (EntryTypes.getStandardType(entryType.getName()) == null) {
                types.put(entryType.getName(), entryType);
            }

            // Check if the entry should be written.
            boolean write = true;

            if (checkSearch && !FileActions.nonZeroField(entry, BibtexFields.SEARCH)) {
                write = false;
            }

            if (checkGroup && !FileActions.nonZeroField(entry, BibtexFields.GROUPSEARCH)) {
                write = false;
            }

            if (write) {
                bibtexEntryWriter.write(entry, writer);
            }
        }

        // Write meta data.
        if (metaData != null) {
            metaData.writeMetaData(writer);
        }

        // Write type definitions, if any:
        if (!types.isEmpty()) {
            for (Map.Entry<String, EntryType> stringBibtexEntryTypeEntry : types.entrySet()) {
                EntryType type = stringBibtexEntryTypeEntry.getValue();
                if (type instanceof CustomEntryType) {
                    CustomEntryType tp = (CustomEntryType) type;
                    CustomEntryTypesManager.save(tp, writer);
                }
            }

        }

        //finally write whatever remains of the file, but at least a concluding newline
        if ((database.getEpilog() != null) && !(database.getEpilog().isEmpty())) {
            writer.write(database.getEpilog());
        } else {
            writer.write(Globals.NEWLINE);
        }
    } catch (IOException ex) {
        LOGGER.error("Could not write file", ex);
        session.cancel();
        // repairAfterError(file, backup, INIT_OK);
        throw new SaveException(ex.getMessage(), ex.getLocalizedMessage(), exceptionCause);
    }

    return session;

}

From source file:com.flexive.faces.FxJsfUtils.java

/**
 * Gets all faces messages (optional: for the given client id).
 *
 * @param clientId the client id to work on, or null to remove all messages.
 * @return a array holding all messages//from www .j a v a  2s  . co  m
 */
@SuppressWarnings("unchecked")
public static ArrayList<FacesMessage> getMessages(String clientId) {
    ArrayList<FacesMessage> result = new ArrayList<FacesMessage>(25);
    try {
        //noinspection unchecked
        Iterator<FacesMessage> it = (clientId == null || clientId.length() == 0)
                ? getCurrentInstance().getMessages()
                : getCurrentInstance().getMessages(clientId);

        while (it.hasNext()) {
            result.add(it.next());
        }
    } catch (Throwable t) {
        result.add(new FacesMessage("Failed to build message list: " + t.getMessage()));
    }
    result.trimToSize();
    return result;
}

From source file:de.qucosa.spring.ResourceExceptionHandler.java

@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
@ExceptionHandler
public void generalExceptionHandler(Throwable ex) {
    log.error(ex.getMessage(), ex);
}

From source file:io.kamax.mxisd.exception.InternalServerError.java

public InternalServerError(Throwable t) {
    this(t.getMessage());
}

From source file:com.alejandroszlv.mock.web.aop.LoggerAopController.java

@AfterThrowing(pointcut = "within(com.alejandroszlv.mock.web.controller..*)", throwing = "e")
public void afterThrowing(JoinPoint joinPoint, Throwable e) {
    LOGGER.error(e.getMessage(), e);
}

From source file:com.alejandroszlv.mock.repository.aop.MockAopRepository.java

@AfterThrowing(pointcut = "within(com.alejandroszlv.mock.repository..*)", throwing = "e")
public void afterThrowing(JoinPoint joinPoint, Throwable e) {
    LOGGER.error(e.getMessage(), e);
}

From source file:com.alejandroszlv.mock.srv.aop.MockAopService.java

@AfterThrowing(pointcut = "within(com.alejandroszlv.mock.srv..*)", throwing = "e")
public void afterThrowing(JoinPoint joinPoint, Throwable e) {
    LOGGER.error(e.getMessage(), e);
}

From source file:com.dtolabs.rundeck.core.execution.impl.jsch.JschNodeExecutor.java

static ExtractFailure extractJschFailure(final INodeEntry node, final int timeout,
        final JSchException jSchException, final Framework framework) {
    String errormsg;/* w w w .j  av  a2  s.co m*/
    FailureReason reason;

    if (null == jSchException.getCause()) {
        if (jSchException.getMessage().contains("Auth cancel")) {

            String msgformat = FWK_PROP_AUTH_CANCEL_MSG_DEFAULT;
            if (framework.getPropertyLookup().hasProperty(FWK_PROP_AUTH_CANCEL_MSG)) {
                msgformat = framework.getProperty(FWK_PROP_AUTH_CANCEL_MSG);
            }
            errormsg = MessageFormat.format(msgformat, node.getNodename(), jSchException.getMessage());
            reason = NodeStepFailureReason.AuthenticationFailure;
        } else if (jSchException.getMessage().contains("Auth fail")) {
            String msgformat = FWK_PROP_AUTH_FAIL_MSG_DEFAULT;
            if (framework.getPropertyLookup().hasProperty(FWK_PROP_AUTH_FAIL_MSG)) {
                msgformat = framework.getProperty(FWK_PROP_AUTH_FAIL_MSG);
            }
            errormsg = MessageFormat.format(msgformat, node.getNodename(), jSchException.getMessage());
            reason = NodeStepFailureReason.AuthenticationFailure;
        } else {
            reason = JschFailureReason.SSHProtocolFailure;
            errormsg = jSchException.getMessage();
        }
    } else {
        Throwable cause = ExceptionUtils.getRootCause(jSchException);
        errormsg = cause.getMessage();
        if (cause instanceof NoRouteToHostException) {
            reason = NodeStepFailureReason.ConnectionFailure;
        } else if (cause instanceof UnknownHostException) {
            reason = NodeStepFailureReason.HostNotFound;
        } else if (cause instanceof SocketTimeoutException) {
            errormsg = "Connection Timeout (after " + timeout + "ms): " + cause.getMessage();
            reason = NodeStepFailureReason.ConnectionTimeout;
        } else if (cause instanceof SocketException) {
            reason = NodeStepFailureReason.ConnectionFailure;
        } else {
            reason = StepFailureReason.Unknown;
        }
    }
    return new ExtractFailure(errormsg, reason);
}