List of usage examples for java.lang Throwable toString
public String toString()
From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java
/** * Logs the message, along with the given <code>throwable</code>, at the error level. If * {@link Logger#getDumpStackTraces() stack traces are not to be dumped}, the logged message will be appended * with the throwable's <code>Throwable.toString()</code> contents. * * @param log where to log the message * @param key the resource key that is associated with the message * @param msg the message to log// ww w. j av a 2 s .c om * @param throwable the throwable associated with the message */ private static void logErrorWithThrowable(Log log, String key, Msg msg, Throwable throwable) { if (Logger.getDumpStackTraces()) { log.error(((Logger.getDumpLogKeys()) ? ('{' + key + '}' + msg) : msg), throwable); } else { log.error(((Logger.getDumpLogKeys()) ? ('{' + key + '}' + msg) : msg) + ". Cause: " + throwable.toString()); } }
From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java
/** * Logs the message, along with the given <code>throwable</code>, at the debug level. If * {@link Logger#getDumpStackTraces() stack traces are not to be dumped}, the logged message will be appended * with the throwable's <code>Throwable.toString()</code> contents. * * @param log where to log the message * @param key the resource key that is associated with the message * @param msg the message to log// www . j ava 2 s .co m * @param throwable the throwable associated with the message */ private static void logDebugWithThrowable(Log log, String key, Msg msg, Throwable throwable) { if (Logger.getDumpStackTraces()) { log.debug(((Logger.getDumpLogKeys()) ? ('{' + key + '}' + msg) : msg), throwable); } else { log.debug(((Logger.getDumpLogKeys()) ? ('{' + key + '}' + msg) : msg) + ". Cause: " + throwable.toString()); } }
From source file:com.sos.i18n.logging.commons.CommonsLogMsg.java
/** * Logs the message, along with the given <code>throwable</code>, at the trace level. If * {@link Logger#getDumpStackTraces() stack traces are not to be dumped}, the logged message will be appended * with the throwable's <code>Throwable.toString()</code> contents. * * @param log where to log the message * @param key the resource key that is associated with the message * @param msg the message to log/*from w w w. j av a 2 s .c om*/ * @param throwable the throwable associated with the message */ private static void logTraceWithThrowable(Log log, String key, Msg msg, Throwable throwable) { if (Logger.getDumpStackTraces()) { log.trace(((Logger.getDumpLogKeys()) ? ('{' + key + '}' + msg) : msg), throwable); } else { log.trace(((Logger.getDumpLogKeys()) ? ('{' + key + '}' + msg) : msg) + ". Cause: " + throwable.toString()); } }
From source file:android.net.http.Connection.java
/** * Helper. Calls the mEventHandler's error() method only if * request failed permanently. Increments mFailcount on failure. * * Increments failcount only if the network is believed to be * connected//www . j a v a 2 s .c om * * @return true if request can be retried (less than * RETRY_REQUEST_LIMIT failures have occurred). */ private boolean httpFailure(Request req, int errorId, Exception e) { boolean ret = true; // e.printStackTrace(); if (HttpLog.LOGV) HttpLog.v("httpFailure() ******* " + e + " count " + req.mFailCount + " " + mHost + " " + req.getUri()); if (++req.mFailCount >= RETRY_REQUEST_LIMIT) { ret = false; String error; if (errorId < 0) { error = mContext.getText(EventHandler.errorStringResources[-errorId]).toString(); } else { Throwable cause = e.getCause(); error = cause != null ? cause.toString() : e.getMessage(); } req.mEventHandler.error(errorId, error); req.complete(); } closeConnection(); mHttpContext.removeAttribute(HTTP_CONNECTION); return ret; }
From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.controller.EditRequestDispatchController.java
@Override protected ResponseValues processRequest(VitroRequest vreq) { try {/*from w ww. j ava 2 s .c o m*/ WebappDaoFactory wdf = vreq.getWebappDaoFactory(); if (isMenuMode(vreq)) { return redirectToMenuEdit(vreq); } //check some error conditions and if they exist return response values //with error message if (isErrorCondition(vreq)) { return doHelp(vreq, getErrorMessage(vreq)); } //if edit form needs to be skipped to object instead if (isSkipPredicate(vreq)) { log.debug("The predicate is a annotated as a skip."); return processSkipEditForm(vreq); } //Get the edit generator name String editConfGeneratorName = processEditConfGeneratorName(vreq); //session attribute setSessionRequestFromEntity(vreq); // make new or get an existing edit configuration EditConfigurationVTwo editConfig = setupEditConfiguration(editConfGeneratorName, vreq); log.debug("editConfiguration:\n" + editConfig); //if the EditConfig indicates a URL to skip to, then redirect to that URL if (editConfig.getSkipToUrl() != null) { return new DirectRedirectResponseValues(editConfig.getSkipToUrl()); } //what template? String template = editConfig.getTemplate(); //Get the multi value edit submission object MultiValueEditSubmission submission = getMultiValueSubmission(vreq, editConfig); MultiValueEditSubmissionTemplateModel submissionTemplateModel = new MultiValueEditSubmissionTemplateModel( submission); //what goes in the map for templates? Map<String, Object> templateData = new HashMap<String, Object>(); EditConfigurationTemplateModel etm = new EditConfigurationTemplateModel(editConfig, vreq); templateData.put("editConfiguration", etm); templateData.put("editSubmission", submissionTemplateModel); //Corresponding to original note for consistency with selenium tests and 1.1.1 templateData.put("title", "Edit"); templateData.put("submitUrl", getSubmissionUrl(vreq)); templateData.put("cancelUrl", etm.getCancelUrl()); templateData.put("editKey", editConfig.getEditKey()); //This may change based on the particular generator? Check if true templateData.put("bodyClasses", "formsEdit"); return new TemplateResponseValues(template, templateData); } catch (Throwable th) { HashMap<String, Object> map = new HashMap<String, Object>(); map.put("errorMessage", th.toString()); log.error(th, th); return new TemplateResponseValues("error-message.ftl", map); } }
From source file:com.jkoolcloud.tnt4j.utils.Utils.java
/** * Obtain string representation of a throwable object * * @param ex//w w w . j a va 2 s . co m * exception * @return string representation including stack trace */ public static String printThrowable(Throwable ex) { try { if (ex == null) return null; ByteArrayOutputStream os = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(os); ex.printStackTrace(ps); return os.toString("UTF8"); } catch (UnsupportedEncodingException e) { return ex.toString(); } }
From source file:com.mirth.connect.client.ui.SettingsPanelDatabaseTasks.java
@Override public void doRefresh() { final String workingId = getFrame().startWorking("Loading database tasks..."); final int selectedRow = taskTable.getSelectedRow(); SwingWorker<Map<String, DatabaseTask>, Void> worker = new SwingWorker<Map<String, DatabaseTask>, Void>() { @Override//from ww w.j a v a 2s . c o m public Map<String, DatabaseTask> doInBackground() throws ClientException { return getFrame().mirthClient.getDatabaseTasks(); } @Override public void done() { try { Map<String, DatabaseTask> databaseTasks = get(); if (databaseTasks == null) { databaseTasks = new HashMap<String, DatabaseTask>(); } Object[][] data = new Object[databaseTasks.size()][4]; int i = 0; for (DatabaseTask databaseTask : databaseTasks.values()) { Status status = databaseTask.getStatus(); data[i][0] = new CellData(status == Status.IDLE ? UIConstants.ICON_BULLET_YELLOW : UIConstants.ICON_BULLET_GREEN, status.toString()); data[i][1] = databaseTask; data[i][2] = databaseTask.getDescription(); data[i][3] = databaseTask.getStartDateTime(); i++; } ((RefreshTableModel) taskTable.getModel()).refreshDataVector(data); if (selectedRow > -1 && selectedRow < taskTable.getRowCount()) { taskTable.setRowSelectionInterval(selectedRow, selectedRow); } } catch (Throwable t) { if (t instanceof ExecutionException) { t = t.getCause(); } getFrame().alertThrowable(getFrame(), t, "Error loading database tasks: " + t.toString()); } finally { getFrame().stopWorking(workingId); } } }; worker.execute(); }
From source file:org.biopax.validator.impl.ValidatorImpl.java
private void execute(ExecutorService exec, final Set<Rule<?>> rules, final Validation validation, final Object obj) { exec.execute(new Runnable() { @SuppressWarnings("unchecked") //obj can be either Model or a BPE public void run() { for (Rule rule : rules) { Behavior behavior = utils.getRuleBehavior(rule.getClass().getName(), validation.getProfile()); if (behavior == Behavior.IGNORE) continue; // skip disabled rule try { if (rule.canCheck(obj)) rule.check(validation, obj); } catch (Throwable t) { //if we're here, there is probably a bug in the rule or validator! String id = validation.identify(obj); log.fatal(rule + ".check(" + id + ") threw the exception: " + t.toString(), t); // anyway, report it almost normally (for a user to see this in the results too) validation.addError( utils.createError(id, "exception", rule.getClass().getName(), null, false, t)); }//from ww w .j av a 2 s . c o m } } }); }
From source file:net.sourceforge.fenixedu.presentationTier.TagLib.OptionsTag.java
/** * Process the end of this tag.//w ww . jav a 2 s. co m * * @exception JspException * if a JSP exception has occurred */ @Override public int doEndTag() throws JspException { // Acquire the select tag we are associated with SelectTag selectTag = (SelectTag) pageContext.getAttribute(Constants.SELECT_KEY); if (selectTag == null) { throw new JspException(messages.getMessage("optionsTag.select")); } StringBuilder sb = new StringBuilder(); // If a collection was specified, use that mode to render options if (collection != null) { Iterator collIterator = getIterator(collection, null); while (collIterator.hasNext()) { Object bean = collIterator.next(); Object value = null; Object label = null; try { value = PropertyUtils.getProperty(bean, property); if (value == null) { value = ""; } } catch (IllegalAccessException e) { throw new JspException(messages.getMessage("getter.access", property, collection)); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); throw new JspException(messages.getMessage("getter.result", property, t.toString())); } catch (NoSuchMethodException e) { throw new JspException(messages.getMessage("getter.method", property, collection)); } try { if (labelProperty != null) { label = PropertyUtils.getProperty(bean, labelProperty); } else { label = value; } if (label == null) { label = ""; } } catch (IllegalAccessException e) { throw new JspException(messages.getMessage("getter.access", labelProperty, collection)); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); throw new JspException(messages.getMessage("getter.result", labelProperty, t.toString())); } catch (NoSuchMethodException e) { throw new JspException(messages.getMessage("getter.method", labelProperty, collection)); } String stringValue = value.toString(); addOption(sb, stringValue, label.toString(), selectTag.isMatched(stringValue)); } } // Otherwise, use the separate iterators mode to render options else { // Construct iterators for the values and labels collections Iterator valuesIterator = getIterator(name, property); Iterator labelsIterator = null; if ((labelName == null) && (labelProperty == null)) { labelsIterator = getIterator(name, property); // Same coll. } else { labelsIterator = getIterator(labelName, labelProperty); } // Render the options tags for each element of the values coll. while (valuesIterator.hasNext()) { String value = valuesIterator.next().toString(); String label = value; if (labelsIterator.hasNext()) { label = labelsIterator.next().toString(); } addOption(sb, value, label, selectTag.isMatched(value)); } } // Render this element to our writer ResponseUtils.write(pageContext, sb.toString()); // Evaluate the remainder of this page return EVAL_PAGE; }
From source file:eionet.cr.api.xmlrpc.XmlRpcServices.java
@Override public Vector getDeliveries(Integer pageNum, Integer pageSize) throws CRException { if (logger.isInfoEnabled()) { logger.info("Entered " + Thread.currentThread().getStackTrace()[1].getMethodName()); }//from w w w.j a v a2s .c om Vector result = new Vector(); if (pageNum == null || pageSize == null || pageNum.intValue() <= 0 || pageSize.intValue() <= 0) { return result; } try { result = DAOFactory.get().getDao(SearchDAO.class) .searchDeliveriesForROD(PagingRequest.create(pageNum, pageSize)); } catch (Throwable t) { t.printStackTrace(); if (t instanceof CRException) { throw (CRException) t; } else { throw new CRException(t.toString(), t); } } return result; }