List of usage examples for java.lang Throwable getMessage
public String getMessage()
From source file:org.fastj.fit.tool.JSONHelper.java
public static String jsonString(Object o) { ObjectMapper mapper = new ObjectMapper(); try {/*from w w w . j a v a2 s . co m*/ return mapper.writerWithDefaultPrettyPrinter().writeValueAsString(o); } catch (Throwable e) { LogUtil.error("GetJSON fail: e={}", e.getMessage()); } return null; }
From source file:com.screenslicer.common.Log.java
public static void exception(Throwable t, String supplementaryMessage) { if (logger == null) { init("screenslicer", true); }/*from w w w . j a va 2 s.c om*/ Level level = Level.SEVERE; String packageName = t.getClass().getName(); for (int i = 0; i < chattyClasses.length; i++) { if (packageName.startsWith(chattyClasses[i])) { level = Level.FINE; break; } } String message = t.getMessage(); message = CommonUtil.isEmpty(message) ? "" : message; logger.log(level, "Exception \"" + message + "\" ~ " + (CommonUtil.isEmpty(supplementaryMessage) ? "" : (supplementaryMessage + " ~ ")) + "Stack trace: " + ExceptionUtils.getStackTrace(t)); }
From source file:com.icesoft.faces.util.CoreUtils.java
public static boolean throwablesEqual(Throwable th1, Throwable th2) { if (th1 == null && th2 == null) return true; if (th1 == null || th2 == null) return false; if (th1.getClass() != th2.getClass()) return false; if (!th1.getMessage().equals(th2.getMessage())) return false; StackTraceElement[] st1 = th1.getStackTrace(); StackTraceElement[] st2 = th2.getStackTrace(); if (st1.length != st2.length) return false; for (int i = 0; i < st1.length; i++) { if (!st1[i].equals(st2[i])) return false; }/*from www.ja v a2 s . c o m*/ return true; }
From source file:com.ibm.soatf.component.file.FileComponent.java
/** * Releases the resources allocated. If either of the objects is null, it is silently ignored and nothing is done * @param session session to release/*from w w w . j av a 2s . c o m*/ * @param channel channel to release */ public static void disconnect(Session session, Channel channel) { if (channel != null) { try { String msg = "Disconnecting from SSH channel..."; logger.debug(msg); channel.disconnect(); msg = "Disconnected from SSH channel."; logger.debug(msg); } catch (Throwable e) { logger.warn("Could not disconnect from SSH channel", e.getMessage()); } } if (session != null) { try { String msg = "Disconnecting from SSH session..."; logger.trace(msg); session.disconnect(); msg = "Disconnected from SSH session."; logger.trace(msg); } catch (Throwable e) { logger.warn("Could not disconnect from SSH session", e.getMessage()); } } }
From source file:com.ikon.servlet.RepositoryStartupServlet.java
/** * Close openkm and free resources// w w w. j a va 2 s .c om */ public static synchronized void stop(GenericServlet gs) { if (!running) { throw new IllegalStateException("openkm not started"); } // Shutdown plugin framework ExtensionManager.getInstance().shutdown(); try { if (!Config.SYSTEM_OPENOFFICE_PATH.equals("")) { log.info("*** Shutting down OpenOffice manager ***"); DocConverter.getInstance().stop(); } } catch (Throwable e) { log.warn(e.getMessage(), e); } log.info("*** Shutting down UI Notification... ***"); uin.cancel(); log.info("*** Shutting down cron... ***"); cron.cancel(); if (Config.UPDATE_INFO) { log.info("*** Shutting down update info... ***"); ui.cancel(); } // Cancel timers cronTimer.cancel(); uinTimer.cancel(); uiTimer.cancel(); log.info("*** Shutting down repository... ***"); if (Config.USER_ITEM_CACHE) { // Serialize try { log.info("*** Cache serialization ***"); UserItemsManager.serialize(); UserNodeKeywordsManager.serialize(); } catch (DatabaseException e) { log.warn(e.getMessage(), e); } } try { // Preserve system user config if (!Config.REPOSITORY_NATIVE) { JcrRepositoryModule.shutdown(); } } catch (Exception e) { log.error(e.getMessage(), e); } log.info("*** Repository shutted down ***"); try { log.info("*** Ejecute stop script ***"); File script = new File(Config.HOME_DIR + File.separatorChar + Config.STOP_SCRIPT); ExecutionUtils.runScript(script); File jar = new File(Config.HOME_DIR + File.separatorChar + Config.STOP_JAR); ExecutionUtils.getInstance().runJar(jar); } catch (Throwable e) { log.warn(e.getMessage(), e); } log.info("*** Shutting down workflow engine... ***"); JbpmContext jbpmContext = JBPMUtils.getConfig().createJbpmContext(); jbpmContext.getJbpmConfiguration().getJobExecutor().stop(); jbpmContext.getJbpmConfiguration().close(); jbpmContext.close(); // openkm is stopped running = false; }
From source file:com.gsbabil.antitaintdroid.UtilityFunctions.java
public static String currentDirectory() { PackageManager pkgManager = MyApp.context.getPackageManager(); String pkgName = MyApp.context.getPackageName(); PackageInfo pkg = new PackageInfo(); try {//from w w w . j a v a 2 s . com pkg = pkgManager.getPackageInfo(pkgName, 0); } catch (Throwable e) { Log.i(MyApp.TAG, e.getMessage().toString()); } return pkg.applicationInfo.dataDir; }
From source file:it.geosolutions.tools.compress.file.Extractor.java
/** * Inflate the provided {@link ZipFile} in the provided output directory. * //from w w w . j a v a 2 s .co m * @param archive * the {@link ZipFile} to inflate. * @param outputDirectory * the directory where to inflate the archive. * @throws IOException * in case something bad happens. * @throws FileNotFoundException * in case something bad happens. */ public static void inflate(ZipFile archive, File outputDirectory, String fileName) throws IOException, FileNotFoundException { final Enumeration<? extends ZipEntry> entries = archive.entries(); try { while (entries.hasMoreElements()) { ZipEntry entry = (ZipEntry) entries.nextElement(); if (!entry.isDirectory()) { final String name = entry.getName(); final String ext = FilenameUtils.getExtension(name); final InputStream in = new BufferedInputStream(archive.getInputStream(entry)); final File outFile = new File(outputDirectory, fileName != null ? new StringBuilder(fileName).append(".").append(ext).toString() : name); final OutputStream out = new BufferedOutputStream(new FileOutputStream(outFile)); IOUtils.copyStream(in, out, true, true); } } } finally { try { archive.close(); } catch (Throwable e) { if (LOGGER.isTraceEnabled()) LOGGER.error("unable to close archive.\nMessage is: " + e.getMessage(), e); } } }
From source file:cc.sion.core.utils.Exceptions.java
/** * ??: ? <-- RootCause??: ?/*from ww w. j ava 2s . c o m*/ */ public static String toStringWithRootCause(@Nullable Throwable t) { if (t == null) { return StringUtils.EMPTY; } final String clsName = ClassUtils.getShortClassName(t, null); final String message = StringUtils.defaultString(t.getMessage()); Throwable cause = getRootCause(t); StringBuilder sb = new StringBuilder(128).append(clsName).append(": ").append(message); if (cause != t) { sb.append("; <---").append(toStringWithShortName(cause)); } return sb.toString(); }
From source file:edu.utah.further.core.ws.HttpUtil.java
/** * Open an HTTP GET method connection to a URL and read the returned response into an * object./*from www.j ava 2 s . c o m*/ * * @param url * remote URL (usually a web service's URL) * @param httpMethod * HTTP method * @return <code>HttpClient</code> {@link HttpMethod} transfer object, containing the * response headers and body */ public static HttpResponseTo getHttpResponse(final String url, final HttpMethod method) { if (log.isDebugEnabled()) { log.debug("Sending HTTP " + method + " request to " + url); } // Create an instance of HttpClient. final HttpClient client = new HttpClient(); // Create a method instance. // Provide custom retry handler is necessary method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(NUMBER_HTTP_REQUEST_TRIALS, false)); try { // Execute the method final int statusCode = client.executeMethod(method); if (statusCode >= 400) { log.error("Method failed: " + method.getStatusLine()); } return new HttpResponseTo(method); } catch (final Throwable e) { if (log.isInfoEnabled()) { log.info("Failed to receive HTTP request from " + url + ": " + e.getMessage()); } } return null; }
From source file:mitll.xdata.dataset.kiva.ingest.KivaIngest.java
public static int executePreparedStatement(PreparedStatement statement, List<String> types, List<String> values) throws Exception { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z"); try {//w w w. ja va 2 s . c o m for (int i = 0; i < types.size(); i++) { String type = TYPE_TO_DB.get(types.get(i).toUpperCase()); String value = values.get(i); if (value != null && value.trim().length() == 0) { value = null; } if (type.equalsIgnoreCase("INT")) { if (value == null) { statement.setNull(i + 1, java.sql.Types.INTEGER); } else { statement.setInt(i + 1, Integer.parseInt(value, 10)); } } else if (type.equalsIgnoreCase("DOUBLE")) { if (value == null) { statement.setNull(i + 1, java.sql.Types.DOUBLE); } else { statement.setDouble(i + 1, Double.parseDouble(value)); } } else if (type.equalsIgnoreCase("BOOLEAN")) { if (value == null) { statement.setNull(i + 1, java.sql.Types.BOOLEAN); } else { statement.setBoolean(i + 1, Boolean.parseBoolean(value)); } } else if (type.equalsIgnoreCase("VARCHAR")) { statement.setString(i + 1, value); } else if (type.equalsIgnoreCase("TIMESTAMP")) { if (value == null) { statement.setNull(i + 1, java.sql.Types.TIMESTAMP); } else { statement.setTimestamp(i + 1, new Timestamp(sdf.parse(value).getTime())); } } } } catch (Throwable e) { System.out.println("types = " + types); System.out.println("values = " + values); System.out.println("types.size() = " + types.size()); System.out.println("values.size() = " + values.size()); e.printStackTrace(); System.out.println(e.getMessage()); throw new Exception(e); } return statement.executeUpdate(); }