List of usage examples for java.lang Throwable getMessage
public String getMessage()
From source file:ch.entwine.weblounge.common.impl.util.TemplateUtils.java
/** * Loads the resource from the classpath. The <code>path</code> denotes the * path to the resource to load, e. g./* w w w .java 2s.com*/ * <code>/ch/o2it/weblounge/test.txt</code>. * * @param path * the resource path * @return the resource */ public static String load(String path) { InputStream is = TemplateUtils.class.getResourceAsStream(path); InputStreamReader isr = null; StringBuffer buf = new StringBuffer(); if (is != null) { try { logger.debug("Loading " + path); isr = new InputStreamReader(is, Charset.forName("UTF-8")); char[] chars = new char[1024]; int count = 0; while ((count = isr.read(chars)) > 0) { for (int i = 0; i < count; i++) buf.append(chars[i]); } return buf.toString(); } catch (Throwable t) { logger.warn("Error reading " + path + ": " + t.getMessage()); } finally { IOUtils.closeQuietly(isr); IOUtils.closeQuietly(is); } logger.debug("Editor support (javascript) loaded"); } else { logger.error("Repository item not found: " + path); } return null; }
From source file:com.contrastsecurity.ide.eclipse.core.ContrastCoreActivator.java
public static void log(Throwable e) { plugin.getLog().log(new Status(IStatus.ERROR, PLUGIN_ID, e.getMessage(), e)); }
From source file:gov.nih.nci.evs.reportwriter.test.lexevs.Util.java
/** * Displays a message to the console, with additional tagging to assist * servicability.//from w w w . ja v a 2s . c o m * * @param message * The message to display. * @param cause * Optional error associated with the message. * @param logID * Optional identifier as registered in the LexBIG logs. */ static void displayTaggedMessage(String message, Throwable cause, String logID) { StringBuffer sb = new StringBuffer("[LB] ").append(message); if (cause != null) { String causeMsg = cause.getMessage(); if (causeMsg != null && !causeMsg.equals(message)) { sb.append(_lineReturn).append("\t*** Cause: ").append(causeMsg); } } if (logID != null) { sb.append(_lineReturn).append("\t*** Refer to message with ID = ").append(logID) .append(" in the log file."); } displayMessage(sb.toString()); }
From source file:org.cleverbus.core.common.exception.ExceptionTranslator.java
/** * Returns error message for root exception. * * @param ex the exception// www . j av a2 s. c o m * @return exception message */ private static String getRootExceptionMessage(Throwable ex) { Assert.notNull(ex, "the ex must not be null"); Throwable rootEx = ExceptionUtils.getRootCause(ex); if (rootEx == null) { rootEx = ex; } return rootEx.getClass().getSimpleName() + ": " + rootEx.getMessage(); }
From source file:ch.entwine.weblounge.common.impl.util.TemplateUtils.java
/** * Loads the resource identified by concatenating the package name from * <code>clazz</code> and <code>path</code> from the classpath. * /*w w w.ja v a 2s . c o m*/ * @param path * the path relative to the package name of <code>clazz</code> * @param clazz * the class * @return the resource */ public static String load(String path, Class<?> clazz) { if (path == null) throw new IllegalArgumentException("path cannot be null"); if (clazz == null) throw new IllegalArgumentException("clazz cannot be null"); String pkg = "/" + clazz.getPackage().getName().replace('.', '/'); InputStream is = clazz.getResourceAsStream(UrlUtils.concat(pkg, path)); InputStreamReader isr = null; StringBuffer buf = new StringBuffer(); if (is != null) { try { logger.debug("Loading " + path); isr = new InputStreamReader(is, Charset.forName("UTF-8")); char[] chars = new char[1024]; int count = 0; while ((count = isr.read(chars)) > 0) { for (int i = 0; i < count; i++) buf.append(chars[i]); } return buf.toString(); } catch (Throwable t) { logger.warn("Error reading " + path + ": " + t.getMessage()); } finally { IOUtils.closeQuietly(isr); IOUtils.closeQuietly(is); } logger.debug("Editor support (javascript) loaded"); } else { logger.error("Repository item not found: " + path); } return null; }
From source file:com.metadave.kash.KashConsole.java
private static void processInput(String line, KashRuntimeContext runtimeCtx) { ANTLRInputStream input = new ANTLRInputStream(line); KashLexer lexer = new KashLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); KashParser parser = new KashParser(tokens); parser.addErrorListener(new KashErrorListener()); ParseTreeWalker walker = new ParseTreeWalker(); KashWalker esq = new KashWalker(runtimeCtx); try {/*from w ww . jav a 2s. c o m*/ KashParser.StmtsContext stmts = parser.stmts(); walker.walk(esq, stmts); } catch (Throwable t) { // catch parse errors. ANTLR will display a message for me. System.out.println(t.getMessage()); } }
From source file:nl.talsmasoftware.enumerables.support.json.jackson2.Compatibility.java
@SuppressWarnings("unchecked") private static <T> T call(Object target, String method) throws NoSuchMethodException { try {//from w w w . j ava2 s . co m return (T) method(target.getClass(), method).invoke(target); } catch (IllegalAccessException iae) { NoSuchMethodException nsme = new NoSuchMethodException( String.format("Not allowed to call method \"%s\": %s", method, iae.getMessage())); nsme.initCause(iae); throw nsme; } catch (InvocationTargetException ite) { Throwable cause = ite.getCause(); if (cause == null) cause = ite; // shouldn't happen! throw cause instanceof RuntimeException ? (RuntimeException) cause : new RuntimeException(cause.getMessage(), cause); } }
From source file:com.metadave.eql.EQLConsole.java
private static void processInput(String line, RuntimeContext runtimeCtx) { ANTLRInputStream input = new ANTLRInputStream(line); EQLLexer lexer = new EQLLexer(input); CommonTokenStream tokens = new CommonTokenStream(lexer); EQLParser parser = new EQLParser(tokens); // combine these two into one parser.addErrorListener(new EQLErrorListener()); ParseTreeWalker walker = new ParseTreeWalker(); EQLWalker esq = new EQLWalker(runtimeCtx); try {/*from w w w .jav a2 s . co m*/ EQLParser.StmtsContext stmts = parser.stmts(); walker.walk(esq, stmts); } catch (Throwable t) { // catch parse errors. ANTLR will display a message for me. System.out.println(t.getMessage()); } }
From source file:com.silverpeas.bootstrap.SilverpeasContextBootStrapper.java
/** * Loads all the JAR libraries available in the SILVERPEAS_HOME/repository/lib directory by using * our own classloader so that we avoid JBoss loads them with its its asshole VFS. *//* w ww .j a v a 2 s . c o m*/ private static void loadExternalJarLibraries() { String libPath = System.getenv("SILVERPEAS_HOME") + separatorChar + "repository" + separatorChar + "lib"; File libDir = new File(libPath); File[] jars = libDir.listFiles(); URL[] jarURLs = new URL[jars.length]; try { for (int i = 0; i < jars.length; i++) { jarURLs[i] = jars[i].toURI().toURL(); } addURLs(jarURLs); String[] classNames = GeneralPropertiesManager.getString(CLASSES_TO_LOAD).split(","); for (String className : classNames) { try { Class aClass = ClassLoader.getSystemClassLoader().loadClass(className); Class<? extends Provider> jceProvider = aClass.asSubclass(Provider.class); Security.insertProviderAt(jceProvider.newInstance(), 0); } catch (Throwable t) { Logger.getLogger(SilverpeasContextBootStrapper.class.getSimpleName()).log(Level.SEVERE, t.getMessage(), t); } } } catch (Exception ex) { Logger.getLogger(SilverpeasContextBootStrapper.class.getSimpleName()).log(Level.SEVERE, ex.getMessage(), ex); } }
From source file:org.gradle.caching.http.internal.HttpBuildCacheService.java
private static BuildCacheException wrap(Throwable e) { if (e instanceof Error) { throw (Error) e; }/* w w w .ja va2 s . com*/ throw new BuildCacheException(e.getMessage(), e); }