List of usage examples for java.lang Throwable getMessage
public String getMessage()
From source file:Main.java
/** * Is the given {@link Exception} due to a 401 Unauthorized API response? * * @param e//from ww w. j a va 2 s . com * @return true if 401, false otherwise */ public static boolean isUnauthorized(final Exception e) { String message = null; if (e instanceof IOException) message = e.getMessage(); final Throwable cause = e.getCause(); if (cause instanceof IOException) { String causeMessage = cause.getMessage(); if (!TextUtils.isEmpty(causeMessage)) message = causeMessage; } if (TextUtils.isEmpty(message)) return false; if ("Received authentication challenge is null".equals(message)) return true; return "No authentication challenges found".equals(message); }
From source file:com.sharneng.net.NetUtils.java
/** * Quietly shutdown the input of a {@linkplain Socket}. Exception are ignored. * /*ww w . ja v a 2s . c om*/ * @param socket * the socket to shutdown the input */ public static void shutdownInput(Socket socket) { if (socket == null) return; try { if (!socket.isInputShutdown()) socket.shutdownInput(); } catch (Throwable e) { log.debug(e.getMessage(), e); } }
From source file:com.sharneng.net.NetUtils.java
/** * Quietly shutdown the output of a {@linkplain Socket}. Exceptions are ignored. * /*from ww w .j av a2s . c o m*/ * @param socket * the socket to shutdown the output * @see Socket#shutdownOutput() */ public static void shutdownOutput(Socket socket) { if (socket == null) return; try { if (!socket.isOutputShutdown()) socket.shutdownOutput(); } catch (Throwable e) { log.debug(e.getMessage(), e); } }
From source file:com.yahoo.elide.core.exceptions.HttpStatusException.java
protected static String formatExceptionCause(Throwable e) { // if the throwable has a cause use that, otherwise the throwable is the cause Throwable error = e.getCause() == null ? e : e.getCause(); return error == null ? null : error.getMessage() == null ? error.toString() : error.getMessage(); }
From source file:com.sharneng.net.NetUtils.java
/** * Quietly close a {@linkplain Socket} object. It tries to shutdown the input and output of the socket before close. * Exceptions are ignored.//from w w w . j av a 2 s. c om * * @param socket * the Socket object to close * @see #shutdown(Socket) */ public static void close(Socket socket) { if (socket == null) return; if (!socket.isClosed()) { shutdown(socket); try { socket.close(); } catch (Throwable e) { log.debug(e.getMessage(), e); } } }
From source file:com.waku.common.http.MyHttpClient.java
private static String getResponse(HttpClient httpclient, HttpRequestBase http) { try {/*from w ww .ja va 2 s .c om*/ logger.info("Executing ---> " + http.getRequestLine()); return httpclient.execute(http, new BasicResponseHandler()); } catch (Throwable e) { logger.info("Exception got ->", e); if (e.getMessage().equalsIgnoreCase("Internal Server Error")) { logger.info("Internal Server Error, seems not recovery-able!"); return null; } logger.info("======== Retry will start after 10 sec ----->"); try { Thread.sleep(10000); } catch (InterruptedException ie) { ie.printStackTrace(); } return getResponse(httpclient, http); } }
From source file:de.micromata.genome.gwiki.utils.ScriptUtils.java
public static Object getScriptObject(String code) { GroovyClassLoader loader = new GroovyClassLoader(Thread.currentThread().getContextClassLoader()); try {//from www . ja v a 2 s .c o m Class<?> cls = loader.parseClass(code); Object obj = cls.newInstance(); return obj; } catch (Throwable ex) { throw new RuntimeException("Cannot execute script Method: " + code + "; " + ex.getMessage(), ex); } }
From source file:com.teradata.benchto.driver.DriverApp.java
private static void logException(Throwable e) { LOG.error("Benchmark execution failed: {}", e.getMessage(), e); if (e instanceof FailedBenchmarkExecutionException) { FailedBenchmarkExecutionException failedBenchmarkExecutionException = (FailedBenchmarkExecutionException) e; for (BenchmarkExecutionResult failedBenchmarkResult : failedBenchmarkExecutionException .getFailedBenchmarkResults()) { LOG.error("--------------------------------------------------------------------------"); LOG.error("Failed benchmark: {}", failedBenchmarkResult.getBenchmark().getUniqueName()); for (Exception failureCause : failedBenchmarkResult.getFailureCauses()) { LOG.error("Cause: {}", failureCause.getMessage(), failureCause); }/*from w w w . j a v a2 s. c om*/ } LOG.error("Total benchmarks failed {} out of {}", failedBenchmarkExecutionException.getFailedBenchmarkResults().size(), failedBenchmarkExecutionException.getBenchmarksCount()); } }
From source file:hermes.Domain.java
public static Domain getDomain(Destination destination) { if (destination instanceof Queue && destination instanceof Topic) { ////from ww w. j av a2 s .co m // This is an interesting hack to deal with WebLogic as it implements both domains. If we see the object // is somewhere in the WLS JMS packages then see if we can get the "topic" property. We must do this dynamically // as it may be loaded in a different class loader (so instanceof will fail) AND we don't want this part of the // Hermes codebase to be coupled to any provider. if (destination.getClass().getName().startsWith("weblogic.jms")) { try { final Boolean isTopic = (Boolean) PropertyUtils.getProperty(destination, "topic"); return isTopic ? Domain.TOPIC : Domain.QUEUE; } catch (Throwable e) { log.error(e.getMessage(), e); return Domain.UNKNOWN; } } else { return Domain.UNKNOWN; } } else if (destination instanceof Queue) { return Domain.QUEUE; } else { return Domain.TOPIC; } }
From source file:gov.nih.nci.ncicb.cadsr.loader.util.BeansAccessor.java
private static BeanFactory getFactoryForSiw() { if (factory == null) { try {/*w ww . j av a 2s . co m*/ factory = new ClassPathXmlApplicationContext(new String[] { "beans.xml" }); } catch (Throwable e) { logger.error(e.getMessage()); throw new RuntimeException(e); } } return factory; }