List of usage examples for java.lang Throwable getMessage
public String getMessage()
From source file:ch.systemsx.cisd.openbis.generic.server.business.bo.DataAccessExceptionTranslator.java
private final static void throwExceptionWithMsg(final DataAccessException exception, final String subject, final EntityKind entityKindOrNull) throws UserFailureException { assert exception != null : "DataAccessException not specified."; final SQLException sqlException = SQLStateUtils.tryGetNextExceptionWithNonNullState(exception); Throwable throwable = exception; if (sqlException != null) { final String sqlState = sqlException.getSQLState(); assert sqlState != null : "SQL state is null"; if (SQLStateUtils.isUniqueViolation(sqlState)) { throw new UserFailureException(String.format(UNIQUE_VIOLATION_FORMAT, subject), exception); } else if (SQLStateUtils.isForeignKeyViolation(sqlState)) { throwForeignKeyViolationException(subject, entityKindOrNull, exception); } else {// www . ja va2 s .c o m throwable = sqlException; } } throw new UserFailureException(throwable.getMessage(), exception); }
From source file:com.stimulus.archiva.service.MessageService.java
protected static void archive(Principal principal, Email message, boolean retry) throws Exception { if (Config.getShutdown()) { throw new ArchiveException(Config.getConfig().getProductName() + " is shutdown", ArchiveException.RecoveryDirective.RETRYLATER); }/* ww w . j av a 2 s . c om*/ Volumes vols = Config.getConfig().getVolumes(); try { if (Config.getConfig().getArchiver().insertMessage(message)) { try { Config.getConfig().getIndex().indexMessage(message); } catch (OutOfMemoryError ofme) { logger.debug("failed index message: out of memory", ofme); } catch (Throwable t) { logger.debug("failed index message:" + t.getMessage(), t); } } } catch (Exception e) { if (e.getCause() instanceof IOException && e.getMessage().contains("space")) { logger.error("must close volume (out of disk space)", e); closeVolume(vols, message.getEmailID().getVolume()); if (!retry) archive(principal, message, true); // retry } audit.error("fail archive email {" + message + ", " + principal + "}"); throw e; } audit.info("archive email {" + message + ", " + principal + "}"); logger.debug("archive email {" + message + ", " + principal + "}"); }
From source file:net.greghaines.jesque.web.controller.JesqueController.java
private static ModelAndView errorModelAndView(final String viewName, final Throwable t, final HttpStatus status) { final ModelAndView model = new ModelAndView(viewName); model.addObject("errorCode", status.value()); model.addObject("errorName", toNiceCase(status.name())); model.addObject("errorType", t.getClass().getName()); model.addObject("errorMessage", t.getMessage()); model.addObject("stackTrace", JesqueUtils.createBacktrace(t).toArray(new String[0])); return model; }
From source file:com.aptana.core.epl.downloader.RepositoryStatusHelper.java
@SuppressWarnings("rawtypes") public static Throwable unwind(Throwable t) { for (;;) {/*ww w . j a v a 2 s . co m*/ Class tc = t.getClass(); // We don't use instanceof operator since we want // the explicit class, not subclasses. // if (tc != RuntimeException.class && tc != InvocationTargetException.class && tc != IOException.class) break; Throwable cause = t.getCause(); if (cause == null) break; String msg = t.getMessage(); if (msg != null && !msg.equals(cause.toString())) break; t = cause; } return t; }
From source file:edu.stolaf.cs.wmrserver.JobServiceHandler.java
public static InternalException wrapException(String message, Throwable cause) { InternalException ex = new InternalException(message); // Serialize cause chain ArrayList<CausingException> causeChain = new ArrayList<CausingException>(); while (cause != null) { CausingException causeStruct = new CausingException(); causeStruct.setMessage(cause.getMessage()); causeStruct.setType(cause.getClass().getName()); // Store stack trace as string StringWriter stackTraceWriter = new StringWriter(); cause.printStackTrace(new PrintWriter(stackTraceWriter)); causeStruct.setStackTrace(stackTraceWriter.toString()); causeChain.add(causeStruct);//from www .ja v a2s. c o m // Move to next in chain and loop cause = cause.getCause(); } ex.setCauses(causeChain); return ex; }
From source file:com.zimbra.soap.SoapCommandUtil.java
private static String formatServiceException(ServiceException e) { Throwable cause = e.getCause(); return "ERROR: " + e.getCode() + " (" + e.getMessage() + ")" + (cause == null ? "" : " (cause: " + cause.getClass().getName() + " " + cause.getMessage() + ")"); }
From source file:com.zimbra.cs.datasource.DataSourceManager.java
private static String generateErrorMessage(Throwable t) { StringBuilder buf = new StringBuilder(); while (t != null) { // HACK: go with JavaMail error message if (t.getClass().getName().startsWith("javax.mail.")) { String msg = t.getMessage(); return msg != null ? msg : t.toString(); }/* w w w .j ava2 s. com*/ if (buf.length() > 0) { buf.append(", "); } String msg = t.getMessage(); buf.append(msg != null ? msg : t.toString()); t = t.getCause(); } return buf.toString(); }
From source file:com.cisco.dvbu.ps.common.util.CompositeLogger.java
/** * log information about the passed exception * /*from w ww .j ava 2 s. c o m*/ * @param e exception to be logged (ignore if null) * @param logMessage detailed message to be logged (can be null). Contain * additional information about the issue to help the developer in diagnosing * the problem */ public static void logException(Throwable ex, String logMessage) { String prependMsg = CommonConstants.applicationErrorPrependMessage; Throwable e = ex; if (e == null) { if (logger.isErrorEnabled()) { logger.error(prependMsg + logMessage); } return; } // if exception is a soap fault exception then extract error message from message entry // if the exception is a remote exception, extract with cause and work // with that if (e instanceof RemoteException) { Throwable remoteCause = e.getCause(); if (remoteCause != null) { e = remoteCause; } } String message = e.getMessage(); if (message == null) { message = prependMsg + defaultMessage; } if (logMessage != null) { message = prependMsg + message + "\n" + logMessage; } Throwable cause = e.getCause(); if (e instanceof CompositeException) { if (e instanceof ApplicationException || (cause != null && cause instanceof ApplicationException)) { if (logger.isWarnEnabled()) { logger.warn(message, e); } } else { if (logger.isErrorEnabled()) { logger.error(message, e); } } } else { if (logger.isErrorEnabled()) { logger.error(message, e); } } }
From source file:de.thischwa.pmcms.tool.InternalAntTool.java
/** * Task to clean up all the generated data and setting. The database will be rebuild. * //from w ww .j a va 2 s . co m * @param dataDir Data directory to use for. * @param props Properties to use for. */ public static void cleanup(final File dataDir, final Properties props) { Project project = buildProject(); Throwable caught = null; try { File sitesDir = new File(dataDir, props.getProperty("pmcms.dir.sites")); // delete the files deleteFile(project, new File(dataDir, ".settings.properties")); deleteDir(project, sitesDir); // make the required directories mkdir(project, new File(dataDir, "sites")); } catch (Exception e) { caught = e; } if (caught != null) project.log("Error while cleanung up: " + caught.getMessage(), caught, Project.MSG_ERR); else project.log("successful finished"); project.fireBuildFinished(caught); }
From source file:com.nary.io.FileUtils.java
/** * Delete all files in the directory whose names match the specified pattern. * @throws MalformedPatternException /*from w w w .j a v a 2 s. co m*/ */ public static void deleteFiles(String _dir, String _pattern) throws IOException, MalformedPatternException { org.apache.oro.text.regex.Perl5Compiler perl = new org.apache.oro.text.regex.Perl5Compiler(); Pattern pattern = perl.compile(escapeFilter(_pattern), Perl5Compiler.CASE_INSENSITIVE_MASK); try { File[] filesToDelete = new File(_dir).listFiles((FileFilter) new CustomFileFilter(pattern, false)); for (int i = 0; i < filesToDelete.length; i++) { filesToDelete[i].delete(); } } catch (Throwable t) { throw new IOException(t.getMessage()); } }