List of usage examples for java.lang Throwable getMessage
public String getMessage()
From source file:org.paxml.launch.Paxml.java
public static String getCause(Throwable t) { String msg = null;/* www .j av a 2 s. c om*/ while (t != null && StringUtils.isNotBlank((msg = t.getMessage()))) { t = t.getCause(); } return msg; }
From source file:io.bitsquare.common.util.Utilities.java
public static void copyToClipboard(String content) { try {/* ww w . j a v a 2 s . c om*/ if (content != null && content.length() > 0) { Clipboard clipboard = Clipboard.getSystemClipboard(); ClipboardContent clipboardContent = new ClipboardContent(); clipboardContent.putString(content); clipboard.setContent(clipboardContent); } } catch (Throwable e) { log.error("copyToClipboard failed " + e.getMessage()); e.printStackTrace(); } }
From source file:com.infinities.skyport.util.JsonUtil.java
public static String toJson(Throwable t) { ObjectNode root = getObjectMapper().createObjectNode(); JsonNode empty = getObjectMapper().createObjectNode(); root.put(JsonConstants.STATUS, 0).put(JsonConstants.MSG, t.getMessage()).put(JsonConstants._DATA, empty); try {/*w w w . j av a2 s . com*/ return getObjectMapper().configure(JsonGenerator.Feature.WRITE_NUMBERS_AS_STRINGS, false) .writeValueAsString(root); } catch (Exception e) { logger.error("json parsing failed", e); throw new RuntimeException(e); } }
From source file:in.bbat.license.LicenseManager.java
private static LicenseInfo parseLicenseEncrypted(String encryptedLic) { if ((encryptedLic == null) || (encryptedLic.trim().isEmpty())) return null; String decryptedLic = EncryptionManager.decrypt(encryptedLic); if ((decryptedLic == null) || (decryptedLic.isEmpty())) return null; try {//ww w . ja v a 2s .c o m byte[] arrayOfByte = Base64.decode(decryptedLic.getBytes("UTF-8")); String decodedLic = new String(arrayOfByte, "UTF-8"); if ((decodedLic == null) || (decodedLic.isEmpty())) return null; return parseLicenseJson(new JSONObject(decodedLic)); } catch (JSONException localJSONException) { LOG.error("Error parsing the license string to JSON:(" + decryptedLic + ")" + localJSONException.getMessage(), localJSONException); return null; } catch (Throwable localThrowable) { LOG.error("Invalid License file found:" + localThrowable.getMessage(), localThrowable); } return null; }
From source file:com.dianping.avatar.cache.util.CacheMonitorUtil.java
private static String getErrorString(Throwable throwable) { OutputStream out = null;/* w ww. j a v a 2 s .c o m*/ PrintWriter writer = null; try { out = new ByteArrayOutputStream(3000); writer = new PrintWriter(out); throwable.printStackTrace(writer); writer.flush(); return out.toString(); } catch (Exception e2) { return throwable.getMessage(); } finally { if (writer != null) { writer.close(); } out = null; writer = null; } }
From source file:br.unb.cic.bionimbuz.services.storage.bucket.CloudStorageService.java
public static boolean fileExistsBuckets(String filename) { try {//from w w w.j av a 2s. c o m for (final BioBucket bucket : bucketList) { final File dataFolder = new File( bucket.getMountPoint() + "/" + BioNimbusConfig.get().getDataFolder()); for (final File file : dataFolder.listFiles()) { if (filename.equals(file.getName())) { return true; } } } } catch (final Throwable t) { LOGGER.error("[CloudStorageService] Exception: " + t.getMessage()); } return false; }
From source file:com.salesforce.ide.core.internal.utils.ForceExceptionUtils.java
public static String getRootCauseMessage(Throwable th, boolean exceptionClassPrefix) { if (th instanceof ForceConnectionException) { return ((ForceConnectionException) th).getExceptionMessage(); }/*from w w w. j av a 2 s .c o m*/ Throwable rootCauseTh = ForceExceptionUtils.getRootCause(th); Throwable finalThrow = (rootCauseTh != null ? rootCauseTh : th); String message = NO_EXCEPTION_MESSAGE_MESSAGE; if (Utils.isNotEmpty(finalThrow.getMessage())) { message = (exceptionClassPrefix ? finalThrow.getClass().getSimpleName() + ": " : "") + finalThrow.getMessage(); } else if (Utils.isNotEmpty(getExceptionMessage(finalThrow))) { message = getExceptionMessage(finalThrow); } return message; }
From source file:it.cnr.icar.eric.client.ui.thin.OutputExceptions.java
/** * Log exceptions and display them to user in a consistent fashion. * * @param log Log where error or warning should be output * @param logMsg Context message to log with t * @param displayMsg Context message to display to user with t * @param t Throwable to log about and optionally display * @param display Output information about this Throwable on page? * @param warning If true, log warning rather than error *//*from ww w . j a v a 2 s.c o m*/ private static void display(Log log, String logMsg, String displayMsg, Throwable t, boolean display, boolean warning) { // When not given a Msg, should we provide context for cause? boolean needContext = (null != t.getMessage() && null != t.getCause()); // Log a fair amount of information unconditionally if (null == logMsg && null != displayMsg) { logMsg = displayMsg; } if (log.isDebugEnabled()) { // Include full traceback in logging output if (null == logMsg) { if (warning) { log.warn(t.toString(), t); } else { log.error(t.toString(), t); } } else { if (warning) { log.warn(logMsg, t); } else { log.error(logMsg, t); } } } else { if (null == logMsg) { if (needContext) { if (warning) { log.warn(t.toString()); } else { log.error(t.toString()); } } } else { if (warning) { log.warn(logMsg); } else { log.error(logMsg); } } if (warning) { log.error(getCause(t, true)); } else { log.error(getCause(t, true)); } } // Conditionally display a subset of the above information to the user if (display) { FacesContext context = FacesContext.getCurrentInstance(); FacesMessage.Severity severity = (warning ? FacesMessage.SEVERITY_ERROR : FacesMessage.SEVERITY_WARN); if (null == displayMsg && null != logMsg) { displayMsg = logMsg; } if (null == displayMsg) { if (needContext) { context.addMessage(null, new FacesMessage(severity, goodMessage(t), null)); } } else { context.addMessage(null, new FacesMessage(severity, displayMsg, null)); } context.addMessage(null, new FacesMessage(severity, getCause(t, false), null)); } }
From source file:de.micromata.genome.gwiki.plugin.vfolder_1_0.GWikiVFolderUtils.java
public static void getPreview(GWikiContext wikiContext, GWikiElement vfileEl, AppendableI sb) { GWikiElement vfe = wikiContext.getWikiWeb() .getElement(vfileEl.getElementInfo().getProps().getStringValue(GWikiVFolderUtils.FVOLDER)); String localName = getLocalFromFilePageId(vfe, vfileEl.getElementInfo().getId()); GWikiVFolderNode fvn = GWikiVFolderNode.getVFolderFromElement(vfe); try {/* w w w.ja v a 2s . c o m*/ byte[] data = fvn.getFileSystem().readBinaryFile(localName); String t = TextExtractorUtils.getTextExtract(wikiContext, vfileEl.getElementInfo().getId(), new ByteArrayInputStream(data)); sb.append(t); } catch (Throwable ex) { GLog.note(GWikiLogCategory.Wiki, "Failure extracting text: " + ex.getMessage()); } }
From source file:eu.eidas.node.utils.EidasNodeErrorUtil.java
/** * @param exc the code of the message * @param messageParameters//from w ww . jav a 2s .co m * @return the text of an error message */ private static String getEidasErrorMessage(AbstractEIDASException exc, Object[] messageParameters) { String errorText = ""; Throwable cause = exc.getCause(); String code = cause == null ? exc.getMessage() : cause.getMessage(); if (cause instanceof EIDASSAMLEngineException) { code = ((EIDASSAMLEngineException) cause).getErrorCode(); } EIDASErrors err = EIDASErrors.fromID(code); if (EIDASErrors.isErrorCode(code) || err != null) { if (err == null) { err = EIDASErrors.fromCode(code); } String message = EIDASUtil.getConfig(err.errorMessage()); errorText = prepareErrorMessage(message, prepareParameters(err, messageParameters), Locale.getDefault()); if (!err.isShowToUser()) { exc.setErrorMessage(""); } } return errorText; }