List of usage examples for java.lang Throwable getMessage
public String getMessage()
From source file:net.sf.firemox.xml.XmlTools.java
/** * @param node/*ww w .ja v a 2s.com*/ * @param tagAttr * @param out * @param nameSpace * @throws IOException * error while writing. */ public static void writeAttrOptions(XmlParser.Node node, String tagAttr, OutputStream out, String nameSpace) throws IOException { final String colorAttr = node.getAttribute(tagAttr); if (colorAttr != null) { final String method = "get" + StringUtils.capitalize(nameSpace); try { final Integer retVal = (Integer) XmlTools.class.getMethod(method, String.class).invoke(null, colorAttr); if (retVal == null) { XmlConfiguration.error("Unknown " + nameSpace + " : '" + colorAttr + "'"); writeConstant(out, 0); } else { writeConstant(out, retVal); } } catch (Throwable e2) { XmlConfiguration.error("Error found in 'get" + nameSpace + "' : " + e2.getMessage()); writeConstant(out, 0); } } else { final XmlParser.Node expr = node.get(tagAttr); if (expr == null) { XmlConfiguration.error("Neither element '" + tagAttr + "' neither attribute '" + tagAttr + "' have been found in element '" + node.getTag() + "'. Context=" + node); return; } writeComplexValue(out, expr); } }
From source file:net.rim.ejde.internal.util.PackageUtils.java
/** * Gets all the source folders of the given <code>iJavaProject</code>. * * @param iJavaProject//from w w w . ja va 2 s . com * @return */ public static ArrayList<IContainer> getAllSrcFolders(IJavaProject iJavaProject) { ArrayList<IContainer> result = new ArrayList<IContainer>(); IProject iProject = iJavaProject.getProject(); IClasspathEntry[] classPathEntries = null; IFolder srcFolder = null; IPath srcFolderPath = null; IPath relativeSrcFolderPath = null; try { classPathEntries = iJavaProject.getRawClasspath(); for (IClasspathEntry classPathEntry : classPathEntries) { if (classPathEntry.getEntryKind() != IClasspathEntry.CPE_SOURCE) { continue; } srcFolderPath = classPathEntry.getPath(); if (srcFolderPath.segment(0).equals(iProject.getName())) { // remove the project name from the path relativeSrcFolderPath = srcFolderPath.removeFirstSegments(1); } if (relativeSrcFolderPath == null || relativeSrcFolderPath.isEmpty()) { result.add(iProject); } else { srcFolder = iProject.getFolder(relativeSrcFolderPath); if (srcFolder.exists()) { result.add(srcFolder); } } } } catch (Throwable e) { _logger.error(e.getMessage(), e); } return result; }
From source file:org.pgptool.gui.tools.ConsoleExceptionUtils.java
public static String getAllMessages(Throwable t) { if (t == null) return ""; StringBuffer ret = new StringBuffer(); Throwable cur = t; while (cur != null) { if (cur == cur.getCause()) break; if (ret.length() > 0) { ret.append(" -> "); }/*from w w w . ja v a 2s . com*/ if (cur instanceof FieldValidationException) { FieldValidationException fve = (FieldValidationException) cur; ret.append(buildMessageForFve(fve, LocaleContextHolder.getLocale())); } else if (cur instanceof HasMessageCode) { ret.append(I18nUtils.buildMessage((HasMessageCode) cur, ac())); } else { try { String className = cur.getClass().getName(); String messageMappingForClassName = Messages.get(className, cur.getMessage()); if (className.equals(messageMappingForClassName)) { throw new NoSuchMessageException(className); } ret.append(messageMappingForClassName); } catch (NoSuchMessageException nfe) { ret.append(cur.getLocalizedMessage()); } } cur = cur.getCause(); } return ret.toString(); }
From source file:org.eclipse.cft.server.core.internal.CloudErrorUtil.java
public static CoreException checkRestException(Throwable t) { String error = getInvalidCredentialsError(t); if (error == null) { if (t instanceof ResourceAccessException && t.getCause() instanceof UnknownHostException) { error = Messages.ERROR_UNABLE_TO_ESTABLISH_CONNECTION_UNKNOWN_HOST; } else if (t instanceof RestClientException) { error = NLS.bind(Messages.ERROR_FAILED_REST_CLIENT, t.getMessage()); }// www. j a va 2 s .c o m } return error != null ? toCoreException(error, t) : toCoreException(t); }
From source file:fedora.server.security.servletfilters.ldap.FilterLdap.java
private static Boolean comparePassword(Attributes attributes, String password, String passwordAttribute) throws PasswordComparisonException { String m = "- comparePassword() "; log.debug(m + ">"); Boolean rc = null;//from w w w . j a va 2 s .c o m try { log.debug(m + "looking for return attribute==" + passwordAttribute); Attribute attribute = attributes.get(passwordAttribute); if (attribute == null) { log.error(m + "null object"); } else { int size = attribute.size(); log.debug(m + "object with n==" + size); for (int j = 0; j < size; j++) { Object o = attribute.get(j); if (password.equals(o.toString())) { log.debug(m + "compares true"); if (rc == null) { log.debug(m + "1st comp: authenticate"); rc = Boolean.TRUE; } else { log.error(m + "dup comp: keep previous rc==" + rc); } } else { log.debug(m + "compares false, -un-authenticate"); if (rc == null) { log.debug(m + "1st comp (fyi)"); } else { log.error(m + "dup comp (fyi)"); } rc = Boolean.FALSE; } } } } catch (Throwable th) { log.error(m + "resetting to null rc==" + rc + th.getMessage()); throw new PasswordComparisonException("in ldap servlet filter", th); } finally { log.debug(m + "< " + rc); } return rc; }
From source file:com.tomtom.speedtools.rest.GeneralExceptionMapper.java
@Nonnull private static String createLogMessage(@Nonnull final String prefix, @Nonnull final Throwable exception, @Nonnull final ExceptionDTO exceptionDTO, @Nonnull final StatusType status) { assert prefix != null; assert exception != null; assert exceptionDTO != null; assert status != null; if (verboseMode) { return String.format(LOG_MESSAGE_TEMPLATE_VERBOSE, prefix, exceptionDTO.getReference(), status, status.getStatusCode(), exception.getMessage(), exceptionDTO.getTime()); } else {/* w ww. j a v a2 s . c o m*/ return String.format(LOG_MESSAGE_TEMPLATE_COMPACT, status, status.getStatusCode(), exception.getMessage()); } }
From source file:it.cnr.icar.eric.client.ui.thin.OutputExceptions.java
/** * Choose a string about Throwable which ignores generic class names * * @param t Throwable of interest//from www . j ava 2s.c o m * t.getMessage() must be non-null when this method is used * @return String message about t */ private static String goodMessage(Throwable t) { String msg; String className = t.getClass().getName(); // TODO: may want to add to this list over time if ("java.lang.Error".equals(className) || "java.lang.Exception".equals(className) || "java.lang.Throwable".equals(className) || "javax.xml.bind.JAXBException".equals(className) || "javax.xml.registry.JAXRException".equals(className) || "javax.xml.registry.RegistryException".equals(className) || "javax.xml.rpc.JAXRPCException".equals(className)) { msg = t.getMessage(); } else { msg = t.toString(); } return msg; }
From source file:com.trsst.Common.java
public static File getClientRoot() { String path = System.getProperty("user.home", "."); File root = new File(path, "trsstd"); path = System.getProperty("com.trsst.client.storage"); if (path != null) { try {// w ww.ja va 2s .c om root = new File(path); root.mkdirs(); } catch (Throwable t) { System.err.println("Invalid path: " + path + " : " + t.getMessage()); } } return root; }
From source file:com.trsst.Common.java
public static File getServerRoot() { String path = System.getProperty("user.home", "."); File root = new File(path, "trsstd"); path = System.getProperty("com.trsst.server.storage"); if (path != null) { try {//ww w . j ava2s . com root = new File(path); root.mkdirs(); } catch (Throwable t) { System.err.println("Invalid path: " + path + " : " + t.getMessage()); } } return root; }
From source file:it.cnr.icar.eric.client.ui.thin.OutputExceptions.java
/** * Find a string which should provide most information about a Throwable. * * @param t Throwable of interest//w ww . j a va 2 s .c o m * @param forLog If true, return more information; going into log * @return String message describing original cause for t */ private static String getCause(Throwable t, boolean forLog) { // Find all causes for this exception ArrayList<Throwable> causes = new ArrayList<Throwable>(); while (null != t) { causes.add(t); t = t.getCause(); } Collections.reverse(causes); // Work backwards through the causes to find the original // (hopefully most informative) detail string Iterator<Throwable> iter = causes.iterator(); String msg = null; while (iter.hasNext() && null == msg) { t = iter.next(); if (null != t.getMessage()) { // Detail string exists if (forLog) { // Always get class information as well msg = t.toString(); } else { msg = goodMessage(t); } } } // No detail found, use class information about root cause if (null == msg) { msg = (causes.get(0)).toString(); } return msg; }