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:org.jmingo.parser.xml.dom.ParserFactory.java

/**
 * Creates parser.//w w  w .  ja  va  2 s . c  o  m
 *
 * @param parseComponent parse component {@link ParseComponent}
 * @param <T>            class
 * @return implementation of {@link org.jmingo.parser.Parser}
 */
public static <T> Parser<T> createParser(ParseComponent parseComponent) {
    Parser xmlParser = null;
    try {
        switch (parseComponent) {
        case CONTEXT:
            xmlParser = new ContextDefinitionParser(createValidatedConfiguration(CONTEXT_XSD),
                    DEFAULT_PARSE_ERROR_HANDLER);
            break;
        case QUERY:
            xmlParser = new QuerySetParser(createValidatedConfiguration(QUERY_XSD),
                    DEFAULT_PARSE_ERROR_HANDLER);
            break;
        default:
            xmlParser = null;
        }
    } catch (ParserConfigurationException ex) {
        LOGGER.error(ExceptionUtils.getMessage(ex));
    }
    return xmlParser;
}

From source file:org.sejda.cli.DefaultTaskExecutionFailedEventListener.java

/**
 * @param event/*from  w w w  .  j  a v  a  2s .  com*/
 * @return string containing the message in the failing cause exception of the event
 */
private String extractFailingCauseMessage(TaskExecutionFailedEvent event) {
    return ExceptionUtils.getMessage(event.getFailingCause());
}

From source file:org.starnub.starnubserver.servers.starbound.UDPProxyServer.java

public void run() {
    InetAddress IPAddress;/*from w w w  . j  ava2s  .  co m*/
    DatagramSocket ds;
    try {
        ds = new DatagramSocket(starnubPort);
        IPAddress = InetAddress.getByName(starboundAddress);
    } catch (SocketException | UnknownHostException e1) {
        StarNub.getLogger().cFatPrint("StarNub", ExceptionUtils.getMessage(e1));
        e1.printStackTrace();
        return;
    }

    byte[] request = new byte[1024];
    byte[] reply = new byte[4096];

    while (!stopping) {
        try {
            DatagramPacket from_client = new DatagramPacket(request, request.length);
            ds.receive(from_client);

            byte[] real_request = new byte[from_client.getLength()];
            System.arraycopy(request, 0, real_request, 0, from_client.getLength());

            DatagramPacket sendPacket = new DatagramPacket(real_request, real_request.length, IPAddress,
                    starboundPort);
            ds.send(sendPacket);

            DatagramPacket from_server = new DatagramPacket(reply, reply.length);
            ds.receive(from_server);
            byte[] real_reply = new byte[from_server.getLength()];
            System.arraycopy(reply, 0, real_reply, 0, from_server.getLength());

            InetAddress address = from_client.getAddress();
            int port = from_client.getPort();
            DatagramPacket to_client = new DatagramPacket(real_reply, real_reply.length, address, port);
            ds.send(to_client);
        } catch (Exception e) {
            StarNub.getLogger().cFatPrint("StarNub", ExceptionUtils.getMessage(e));
            return;
        }
    }
}

From source file:org.xwiki.environment.internal.ServletEnvironment.java

@Override
protected String getTemporaryDirectoryName() {
    final String tmpDirectory = super.getTemporaryDirectoryName();
    try {//from w  ww.  ja v a 2  s  .  c o m
        if (tmpDirectory == null) {
            File tempDir = (File) this.getServletContext().getAttribute("javax.servlet.context.tempdir");
            return tempDir == null ? null : tempDir.getCanonicalPath();
        }
    } catch (IOException e) {
        this.logger.warn(
                "Unable to get Servlet temporary directory due to error [{}], "
                        + "falling back on the default System temporary directory.",
                ExceptionUtils.getMessage(e));
    }
    return tmpDirectory;
}

From source file:org.xwiki.management.internal.DefaultJMXBeanRegistration.java

@Override
public void registerMBean(Object mbean, String name) {
    // Make sure we never fail since XWiki should execute correctly even if there's no MBean Server running.
    try {/*from   ww w  .  j a  v a  2  s  .  c o m*/
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        ObjectName oname = new ObjectName(OBJECTNAME_PREFIX + name);
        mbs.registerMBean(mbean, oname);
        this.logger.debug("Registered resource with name [{}]", name);
    } catch (Exception e) {
        // Failed to register the MBean, log a warning
        this.logger.warn("Failed to register resource with name [{}]. Reason = [{}]", name,
                ExceptionUtils.getMessage(e));
    }
}

From source file:org.xwiki.management.internal.DefaultJMXBeanRegistration.java

@Override
public void unregisterMBean(String name) {
    // Make sure we never fail since XWiki should execute correctly even if it fail to unregister some MBean
    try {// w  w  w. j  a v a 2 s. c  o m
        MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
        ObjectName oname = new ObjectName(OBJECTNAME_PREFIX + name);
        mbs.unregisterMBean(oname);
        this.logger.debug("Unregistered resource with name [{}]", name);
    } catch (Exception e) {
        // Failed to unregister the MBean, log a warning
        this.logger.warn("Failed to unregister resource with name [{}]. Reason = [{}]", name,
                ExceptionUtils.getMessage(e));
    }
}

From source file:petascope.wms2.service.exception.error.WMSInternalException.java

/**
 * Constructor for the class/* w  ww .  jav  a 2s .  co m*/
 *
 * @param e the internal exception
 */
public WMSInternalException(Exception e) {
    super(ERROR_MESSAGE.replace("$Message", ExceptionUtils.getMessage(e)));
}

From source file:pl.exsio.ck.comparator.retriever.notfound.ThreadsNotFoundSerialsRetrieverImpl.java

protected void joinWorkerThreads(List<Thread> threads) {
    threads.stream().forEach((t) -> {
        try {/*from w  w w  .  ja v  a 2  s.  c  o  m*/
            t.join();
        } catch (InterruptedException ex) {
            this.log.log("podczas porwnywania wystpi bd");
            this.log.log(ExceptionUtils.getMessage(ex));
        }
    });
}

From source file:pl.exsio.ck.logging.presenter.LogPresenterImpl.java

@Override
public void logThrowable(Throwable t) {
    this.log(ExceptionUtils.getMessage(t));
    this.log(ExceptionUtils.getStackTrace(t));
}

From source file:pl.exsio.ck.model.reader.XlsxEntryReaderImpl.java

@Override
public Collection<Entry> readEntries(File file, String progressName, boolean serialsOnly) {
    ProgressPresenter progress = ProgressHelper.showProgressBar(progressName, false);
    Row currentRow = null;/* w  w  w . j  a  v  a 2s .  c o m*/
    Cell currentCell = null;
    ArrayList<Entry> entries = new ArrayList<>();
    try {
        XSSFSheet sheet = this.openSheet(file);

        Iterator<Row> rowIterator = sheet.iterator();
        int totalRowCount = sheet.getPhysicalNumberOfRows() - 1;
        int rowCounter = 0;
        while (rowIterator.hasNext()) {
            ProgressHelper.updateProgressBar(progress, (int) (rowCounter * 100 / totalRowCount));
            currentRow = rowIterator.next();
            if (currentRow.getRowNum() > 0) {
                Entry e = new EntryImpl();
                Iterator<Cell> cellIterator = currentRow.cellIterator();
                while (cellIterator.hasNext()) {
                    currentCell = cellIterator.next();
                    if (!this.fillEntryField(currentCell, e, serialsOnly)) {
                        break;
                    }
                }
                if (e.getSerialNo() != null) {
                    entries.add(e);
                }
            }
            rowCounter++;
        }
    } catch (IOException ex) {
        this.log.log("nieudana prba otwarcia pliku " + file.getAbsolutePath());
        this.log.log(ExceptionUtils.getMessage(ex));
    } catch (ParseException ex) {
        this.log.log("nieprawidowy format daty w komrce " + currentRow.getRowNum()
                + CellReference.convertNumToColString(currentCell.getColumnIndex())
                + ". Akceptowalny format to 'yyyy-mm-dd'");
        this.log.log(ExceptionUtils.getMessage(ex));
    }
    System.gc();
    ProgressHelper.hideProgressBar(progress);
    return entries;
}