List of usage examples for org.apache.commons.lang.exception ExceptionUtils getRootCauseMessage
public static String getRootCauseMessage(Throwable th)
From source file:mitm.common.fetchmail.FetchmailConfigWriter.java
public static void main(String[] args) { try {// w w w .jav a 2 s .co m FetchmailConfigWriter configurator = new FetchmailConfigWriter(args); configurator.writeConfig(); } catch (JAXBException e) { System.err.println("Error reading input. " + ExceptionUtils.getRootCauseMessage(e)); } catch (IllegalArgumentException e) { System.err.println("Illegal argument. " + ExceptionUtils.getRootCauseMessage(e)); } catch (FileNotFoundException e) { System.err.println("File not found. " + ExceptionUtils.getRootCauseMessage(e)); } catch (IOException e) { System.err.println("Error reading file. " + ExceptionUtils.getRootCauseMessage(e)); } }
From source file:com.dianping.lion.util.DBUtils.java
/** * warn: spring delegate sqlmapclient?/* w w w.jav a 2 s .c o m*/ * @param throwable * @return */ public static boolean isDuplicateKeyError(Throwable throwable) { if (throwable == null) { return false; } return ExceptionUtils.indexOfType(throwable, DataIntegrityViolationException.class) != -1 && ExceptionUtils.getRootCauseMessage(throwable).contains("Duplicate entry"); }
From source file:mitm.application.djigzo.ws.WSExceptionUtils.java
public static String getExceptionMessage(Throwable t) { Throwable cause = ExceptionUtils.getRootCause(t); if (cause == null) { cause = t;/*from w ww .ja v a 2s . com*/ } return ExceptionUtils.getRootCauseMessage(t) + ", Class: " + cause.getClass(); }
From source file:common.exceptions.support.RuntimeExceptionMapper.java
/** * {@inheritDoc}// w w w.j av a 2 s .c o m */ @Override public Response toResponse(RuntimeException re) { ServiceException ex; Response response; if (re instanceof ValidationException) { ex = (ValidationException) re; response = ResponseBuilder.build(Response.Status.fromStatusCode(ex.getEventLogId().getResponseId()), ((ValidationException) re).getMessages()); } else if (re instanceof ServiceException) { ex = (ServiceException) re; response = ResponseBuilder.build(Response.Status.fromStatusCode(ex.getEventLogId().getResponseId()), String.valueOf(ex.getEventLogId().getEventId()), ex.getMessage()); } else { ex = new ServiceException(re, HttpEventLogId.UnexpectedException, ExceptionUtils.getRootCauseMessage(re)); response = ResponseBuilder.build(Response.Status.INTERNAL_SERVER_ERROR, String.valueOf(ex.getStatusCode()), ExceptionUtils.getFullStackTrace(re)); } if (re instanceof WebApplicationException) { if (re.getCause() instanceof ServiceException) { ex = (ServiceException) re.getCause(); response = ResponseBuilder.build(Response.Status.INTERNAL_SERVER_ERROR, String.valueOf(ex.getEventLogId().getEventId()), ex.getMessage()); } else { ex = new ServiceException(re, HttpEventLogId.UnexpectedException, ExceptionUtils.getRootCauseMessage(re)); response = ResponseBuilder.build( Response.Status.fromStatusCode(((WebApplicationException) re).getResponse().getStatus()), String.valueOf(((WebApplicationException) re).getResponse().getStatus()), ExceptionUtils.getFullStackTrace(re)); } } ex.log(LOGGER); return response; }
From source file:fusejext2.JextThreadFactory.java
@Override public synchronized Thread newThread(Runnable r) { final String name = new StringBuilder().append(threadPrefix).append("[").append(count.getAndIncrement()) .append("]").toString(); Thread t = new Thread(r); t.setName(name);//from www . ja v a 2 s . c om t.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override public void uncaughtException(Thread t, Throwable e) { logger.severe(new StringBuffer().append("Uncaught Exception in thread ").append(name).append("\n") .append(ExceptionUtils.getMessage(e)).append(", ") .append(ExceptionUtils.getRootCauseMessage(e)).append("\n") .append(ExceptionUtils.getFullStackTrace(e)).toString()); logger.severe("Shutting down due to unexpected exception.."); System.exit(23); } }); logger.info("Created new Thread: " + name); return t; }
From source file:de.tudarmstadt.ukp.dkpro.tc.integrationtest.ExtremeConfiguratonSettingsTest.java
@Test public void testExtremeValues_emptyFeatureExtractorSet() throws Exception { try {// w w w . ja v a 2 s .co m new ExtremeConfigurationSettingsExperiment().runEmptyFeatureExtractorSet(); } catch (ExecutionException e) { if (!ExceptionUtils.getRootCauseMessage(e) .contains("No feature extractors have been added to the experiment.")) { Assert.fail("Unexpected exception"); } } }
From source file:mitm.common.util.LogUtils.java
/** * Logs on error level. Only logs stacktrace if debug is enabled *///from w w w . ja v a 2 s . co m public static void logErrorStackTraceOnDebug(org.slf4j.Logger logger, String message, Throwable t) { if (logger.isDebugEnabled()) { logger.error(message, t); } else { logger.error(message + ", Message: " + ExceptionUtils.getRootCauseMessage(t)); } }
From source file:de.tudarmstadt.ukp.clarin.webanno.brat.dao.DaoUtilsTest.java
@SuppressWarnings("resource") @Test/* w w w. j a v a 2 s . com*/ public void testZipFolder() { File toBeZippedFiles = new File("src/test/resources"); File zipedFiles = new File("target/" + toBeZippedFiles.getName() + ".zip"); try { ZipUtils.zipFolder(toBeZippedFiles, zipedFiles); } catch (Exception e) { LOG.info("Zipping fails" + ExceptionUtils.getRootCauseMessage(e)); } FileInputStream fs; try { fs = new FileInputStream(zipedFiles); ZipInputStream zis = new ZipInputStream(fs); ZipEntry zE; while ((zE = zis.getNextEntry()) != null) { for (File toBeZippedFile : toBeZippedFiles.listFiles()) { if ((FilenameUtils.getBaseName(toBeZippedFile.getName())) .equals(FilenameUtils.getBaseName(zE.getName()))) { // Extract the zip file, save it to temp and compare ZipFile zipFile = new ZipFile(zipedFiles); ZipEntry zipEntry = zipFile.getEntry(zE.getName()); InputStream is = zipFile.getInputStream(zipEntry); File temp = File.createTempFile("temp", ".txt"); OutputStream out = new FileOutputStream(temp); IOUtils.copy(is, out); FileUtils.contentEquals(toBeZippedFile, temp); } } zis.closeEntry(); } } catch (FileNotFoundException e) { LOG.info("zipped file not found " + ExceptionUtils.getRootCauseMessage(e)); } catch (IOException e) { LOG.info("Unable to get file " + ExceptionUtils.getRootCauseMessage(e)); } }
From source file:com.adaptris.core.services.exception.ExceptionAsString.java
@Override public void serialize(Exception exc, AdaptrisMessage msg) throws CoreException { try {//from w ww. j a va2 s.c o m if (includeStackTrace()) { target.insert(ExceptionUtils.getFullStackTrace(exc), msg); } else { target.insert(ExceptionUtils.getRootCauseMessage(exc), msg); } } catch (Exception e) { throw ExceptionHelper.wrapCoreException(e); } }
From source file:mitm.common.util.LogUtils.java
/** * Logs on warn level. Only logs stacktrace if debug is enabled *//* w w w.j av a 2s . c om*/ public static void logWarnStackTraceOnDebug(org.slf4j.Logger logger, String message, Throwable t) { if (logger.isDebugEnabled()) { logger.warn(message, t); } else { logger.warn(message + ", Message: " + ExceptionUtils.getRootCauseMessage(t)); } }