List of usage examples for java.lang Throwable getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:fr.paris.lutece.portal.service.util.AppException.java
private void writeToLogs() { StringBuilder sb = new StringBuilder("Critical AppException"); Throwable strRootCause = ExceptionUtils.getRootCause(this); if (strRootCause != null) { sb.append(", root cause: "); String strShortName = strRootCause.getClass().getSimpleName(); sb.append(strShortName);/* ww w .j a v a 2 s.c o m*/ } Throwable throwableForMessage = strRootCause == null ? this : strRootCause; String strMessage = throwableForMessage.getMessage(); if (strMessage != null) { sb.append(": "); sb.append(strMessage); } String strHeader = sb.toString(); AppLogService.error(strHeader, this); }
From source file:com.datasalt.pangool.solr.BatchWriter.java
protected UpdateResponse runUpdate(List<SolrInputDocument> batchToWrite) { try {/* w w w . j a v a2s . c o m*/ UpdateResponse result = solr.add(batchToWrite); SolrRecordWriter.incrementCounter(taskId, "SolrRecordWriter", "BatchesWritten", 1); SolrRecordWriter.incrementCounter(taskId, "SolrRecordWriter", "DocumentsWritten", batchToWrite.size()); SolrRecordWriter.incrementCounter(taskId, "SolrRecordWriter", "BatchesWriteTime", result.getElapsedTime()); return result; } catch (Throwable e) { SolrRecordWriter.incrementCounter(taskId, "SolrRecordWriter", e.getClass().getName(), 1); if (e instanceof Exception) { setBatchWriteException((Exception) e); } else { setBatchWriteException(new Exception(e)); } return null; } }
From source file:hjow.hgtable.util.DataUtil.java
/** * <p>, ? ?? ? ? . ?? ? ? ?? .</p> * //from w w w . ja va2 s . c o m * @param t : , ? ? * @return ? */ public static String stackTrace(Throwable t) { StringBuffer results = new StringBuffer(""); results = results.append(t.getClass().getName() + ": " + t.getMessage() + "\n"); StackTraceElement[] traces = t.getStackTrace(); for (StackTraceElement e : traces) { results = results.append("\tat " + String.valueOf(e) + "\n"); } return results.toString(); }
From source file:com.diversityarrays.kdxplore.trials.TrialDataBackgroundTask.java
@Override final public void onException(Throwable cause) { String errmsg = DalUtil.extractPossibleDalErrorMessage(cause); if (errmsg == null) { errmsg = cause.getMessage();/*from w ww .ja v a 2s . c om*/ if (Check.isEmpty(errmsg)) { errmsg = cause.getClass().getName() + " during " + this.getMessage(); } GuiUtil.errorMessage(messageComponent, cause, "Error doing: " + this.getMessage()); } messageLogger.e(tag, errmsg); errorConsumer.execute(errmsg); }
From source file:com.moss.bdbwrap.util.TxAbortFailureTool.java
public void handle(Throwable err, Transaction t) { try {/*from ww w .j ava 2 s. c o m*/ t.abort(); throw new RuntimeException("Transaction rolled back", err); } catch (DatabaseException e) { String message = "The transaction was aborted due to a " + err.getClass().getSimpleName() + ", but we received a subsequent error rolling back the transaction: " + e.getMessage(); log.error(message + ". Here is the full stack trace of the original throwable.", err); throw new RuntimeException(message, e); } }
From source file:de.tudarmstadt.lt.utilities.annotators.StopwordTokenFilter.java
@Override public void initialize(UimaContext context) throws ResourceInitializationException { super.initialize(context); _stopwords = new HashSet<String>(); LOG.debug("Stopword file: {}.", _stopwordsfile); if (_stopwordsfile != null) { LOG.info("Reading stopword file: {}.)", new File(_stopwordsfile.getFile()).getAbsolutePath()); // if (!(_stopwordsfile.exists() && _stopwordsfile.isFile())) { // // TODO: maintain default stopword list in classpath // }/* w ww .j ava 2 s . c om*/ try { for (String line : IOUtils.readLines(new FileReader(_stopwordsfile.getFile()))) _stopwords.add(line.trim().toLowerCase()); } catch (Throwable t) { for (int i = 0; t != null; i++) { LOG.error(String.format("Failed to read stopword file: %s (%d-%s: %s).)", _stopwordsfile, i, t.getClass().getName(), t.getMessage()), t); t = t.getCause(); } _stopwords = Collections.emptySet(); } } }
From source file:com.altoros.layout.JSONLayout.java
/** * Converts LoggingEvent Throwable to JSON object * @param json/*w w w . j a v a 2s.c o m*/ * @param event * @throws JSONException */ protected void writeThrowable(JSONObject json, LoggingEvent event) throws JSONException { ThrowableInformation ti = event.getThrowableInformation(); if (ti != null) { Throwable t = ti.getThrowable(); JSONObject throwable = new JSONObject(); throwable.put("message", t.getMessage()); throwable.put("className", t.getClass().getCanonicalName()); List<JSONObject> traceObjects = new ArrayList<JSONObject>(); for (StackTraceElement ste : t.getStackTrace()) { JSONObject element = new JSONObject(); element.put("class", ste.getClassName()); element.put("method", ste.getMethodName()); element.put("line", ste.getLineNumber()); element.put("file", ste.getFileName()); traceObjects.add(element); } json.put("stackTrace", traceObjects); json.put("throwable", throwable); } }
From source file:com.lucidtechnics.blackboard.util.error.ErrorManager.java
public void throwException(Throwable _t, Log _logger) { logException(_t, _logger);//from ww w . jav a 2 s .com if (_logger.isDebugEnabled() == true) { _logger.debug("ErrorManager Found this exception: " + _t.getClass()); } if ((_t instanceof BlackboardException) == true) { throw (BlackboardException) _t; } else { throw new BlackboardException(_t); } }
From source file:eu.nubomedia.tutorial.repository.RepositoryHandler.java
@Override public void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { try {//from ww w .jav a 2s .co m JsonObject jsonMessage = new GsonBuilder().create().fromJson(message.getPayload(), JsonObject.class); log.info("Incoming message: {}", jsonMessage); switch (jsonMessage.get("id").getAsString()) { case "start": start(session, jsonMessage); break; case "stop": stop(session); break; case "stopPlay": stopPlay(session); break; case "play": play(session, jsonMessage); break; case "onIceCandidate": { onIceCandidate(session, jsonMessage); break; } default: error(session, "Invalid message with id " + jsonMessage.get("id").getAsString()); break; } } catch (NotEnoughResourcesException e) { log.warn("Not enough resources", e); notEnoughResources(session); } catch (Throwable t) { log.error("Exception starting session", t); error(session, t.getClass().getSimpleName() + ": " + t.getMessage()); } }
From source file:com.blocks.framework.utils.date.StringUtil.java
/** * // w w w .j a v a2 s .c o m * @param t * @return */ public static String throwableToString(Throwable t) { StringBuffer sb = new StringBuffer(); sb.append(t.getClass().getName()); if (t.getMessage() != null) { ByteArrayOutputStream bo = new ByteArrayOutputStream(); t.printStackTrace(new PrintStream(bo)); sb.append(":\r\n\t" + bo.toString()); } return sb.toString(); }