List of usage examples for java.lang Throwable getCause
public synchronized Throwable getCause()
From source file:com.jaspersoft.studio.server.editor.ReportRunControler.java
public void setReportUnit(String key) { if (!key.equals(reportUnit)) { repExec = new ReportExecution(); repExec.setStatus("queued"); //$NON-NLS-1$ repExec.setReportURIFull(key);//from w ww. j ava 2 s. c om repExec.setReportURI(WSClientHelper.getReportUnitUri(key)); } this.reportUnit = key; if (viewmap != null && prmInput == null) { try { icm = new InputControlsManager(); ProgressMonitorDialog pm = new ProgressMonitorDialog(UIUtils.getShell()); pm.run(true, true, new IRunnableWithProgress() { public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { monitor.beginTask(com.jaspersoft.studio.messages.Messages.ReportRunControler_1, IProgressMonitor.UNKNOWN); try { cli = WSClientHelper.getClient(monitor, reportUnit); icm.setWsclient(cli); icm.initInputControls( cli.initInputControls(reportUnit, ResourceDescriptor.TYPE_REPORTUNIT, monitor)); // TODO search all the repository icm.getDefaults(); UIUtils.getDisplay().syncExec(new Runnable() { public void run() { if (viewmap != null) fillForms(monitor); runReport(); } }); } catch (Throwable e) { throw new InvocationTargetException(e); } finally { monitor.done(); } } }); } catch (InvocationTargetException e) { UIUtils.showError(e.getCause()); } catch (InterruptedException e) { UIUtils.showError(e); } catch (Exception e1) { UIUtils.showError(e1); } } else { runReport(); } }
From source file:com.flexive.shared.exceptions.FxApplicationException.java
/** * Return the localized messages of any chained exceptions that are derived from FxException * * @param language the language/* ww w . j a va 2 s . co m*/ * @return the localized messages of any chained exceptions that are derived from FxException */ private String evaluateCause(FxLanguage language) { final StringBuilder msg = new StringBuilder(); Throwable org = this.getCause(); while (org != null) { if (org instanceof FxApplicationException) { if (!this.message.equals(((FxApplicationException) org).message)) msg.append(((FxApplicationException) org).message.getLocalizedMessage(language)); } org = org.getCause(); } return msg.toString(); }
From source file:com.surevine.alfresco.presence.xmpp.XMPPPresenceServiceImpl.java
protected boolean hasCause(Throwable t, Class<?> c) { if (!Throwable.class.isInstance(c)) { return false; }// w w w . ja v a 2 s .co m Throwable top = t; if (c.isInstance(top)) { return true; } while (top.getCause() != null) { top = top.getCause(); if (c.isInstance(top)) { return true; } } return false; }
From source file:it.attocchi.jsf2.PageBase.java
protected void addErrorMessage(String summary, Throwable ex) { if (ex != null && ex.getMessage() != null) { if (summary != null) { if (ex.getCause() == null) { logger.error(summary, ex); getFacesContext().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, summary, ex.getMessage())); } else { logger.error(summary, ex.getCause()); getFacesContext().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, summary, ex.getCause().getMessage())); }//from w w w. j a v a2 s . c o m } else { if (ex.getCause() == null) { logger.error(ex); summary = ex.getMessage(); getFacesContext().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, summary, "")); } else { logger.error(ex.getCause()); summary = ex.getCause().getMessage(); getFacesContext().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, summary, "")); } } } else { String errorMessage = (summary != null && !summary.isEmpty()) ? summary : "Error"; logger.error(errorMessage, ex); getFacesContext().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, errorMessage, "Null")); } }
From source file:com.mirth.connect.server.api.providers.MirthResourceInvocationHandlerProvider.java
private Throwable convertThrowable(Throwable t, Set<Throwable> visited) { // If the target is null or we've already seen it, ignore if (t == null || visited.contains(t)) { return null; }//from ww w .j a v a 2s . c o m // Add the target to set of visited visited.add(t); // Recursively convert the causes Throwable cause = t.getCause(); Throwable convertedCause = convertThrowable(cause, visited); if (t instanceof PersistenceException) { // Always convert this exception return new com.mirth.connect.client.core.api.PersistenceException(t.getMessage(), convertedCause != null ? convertedCause : cause); } else if (t instanceof WebApplicationException) { // This exception may contain an underlying exception stored in a JAX-RS response Response response = ((WebApplicationException) t).getResponse(); Response convertedResponse = null; if (response != null && response.hasEntity()) { Object entity = response.getEntity(); if (entity instanceof Throwable) { Object convertedEntity = convertThrowable((Throwable) entity, visited); if (convertedEntity != null) { convertedResponse = Response.fromResponse(response).entity(convertedEntity).build(); } } } if (convertedResponse != null) { return new MirthApiException(convertedResponse); } else if (convertedCause != null) { return new MirthApiException(convertedCause); } } else if (t instanceof InvocationTargetException) { // Ensure that this exception always has a cause of WebApplicationException if (convertedCause != null) { if (!(convertedCause instanceof WebApplicationException)) { convertedCause = new MirthApiException(convertedCause); } return new InvocationTargetException(convertedCause); } else if (cause != null && !(cause instanceof WebApplicationException)) { return new InvocationTargetException(new MirthApiException(cause)); } } else if (convertedCause != null) { // Any other types, just construct a new instance with the converted cause try { try { return t.getClass().getConstructor(String.class, Throwable.class).newInstance(t.getMessage(), convertedCause); } catch (Throwable t2) { // Ignore and return null } return t.getClass().getConstructor(Throwable.class).newInstance(convertedCause); } catch (Throwable t3) { // Ignore and return null } } return null; }
From source file:de.tudarmstadt.lt.lm.service.UimaStringProvider.java
public List<String>[] getNgramsInner(String text, String language_code, String docid, int splitcount, int casExceptionCount) throws RemoteException, Exception { int maxLengthSplitHeuristic = Properties.maxLengthSplitHeuristic(); if (maxLengthSplitHeuristic > 0 && text.length() > maxLengthSplitHeuristic) { List<String>[] result = null; Iterator<String> text_splits_iter = applySplitHeuristic(text, splitcount); for (int i = 0; text_splits_iter.hasNext(); i++) { String docid_i = String.format("%s.%d", docid, i); List<String>[] intermediate_result = getNgramsInner(text_splits_iter.next().trim(), language_code, docid_i, splitcount + 1, 0); if (result == null) result = intermediate_result; else//from ww w . j a v a2s . c o m result = ArrayUtils.getConcatinatedArray(result, intermediate_result); } return result; } synchronized (_processing_engine_lck) { List<String>[] result = null; JCas aJCas = null; try { aJCas = _processing_engine.newJCas(); } catch (Throwable t) { for (int i = 0; t != null; i++) { LOG.error( String.format("Failed to initialize cas: %s '%s' (%d-%s: %s).)", docid, StringUtils.abbreviate(text, 50), i, t.getClass().getName(), t.getMessage()), t); t = t.getCause(); } return EMPTY_NGRAM_LIST; } aJCas.setDocumentText(text); DocumentMetaData meta = DocumentMetaData.create(aJCas); meta.setDocumentId(docid); meta.setDocumentTitle(StringUtils.abbreviate(text, 30)); aJCas.getCas().setDocumentLanguage(language_code); // aJCas.setDocumentLanguage(language_code); meta.setLanguage(language_code); LOG.debug("[{}] Pre-processing text '{}'...", docid, StringUtils.abbreviate(text, 50)); try { _processing_engine.process(aJCas); } catch (Throwable t) { for (int i = 0; t != null; i++) { LOG.error( String.format("Failed to process cas: %s '%s' (%d-%s: %s).)", docid, StringUtils.abbreviate(text, 50), i, t.getClass().getName(), t.getMessage()), t); t = t.getCause(); } LOG.error("Reactivating cas engine."); setEngineDescription(getEngineDescription()); LOG.error("Cas engine reactivated."); if (casExceptionCount++ < 1) { LOG.error("Reprocessing cas {}.", docid); return getNgramsInner(text, language_code, docid, splitcount, casExceptionCount); } LOG.error("Cas engine exception counter has reached its limit. Cas {} will be skipped.", docid); return EMPTY_NGRAM_LIST; } result = getNgramsFromSentencesFromCas(aJCas); return result; } }
From source file:com.jaspersoft.studio.server.action.resource.PasteResourceAction.java
@Override public void run() { final ANode parent = getSelected(); final List<?> list = (List<?>) Clipboard.getDefault().getContents(); if (list == null) return;// ww w . j a v a 2s . c o m ProgressMonitorDialog pm = new ProgressMonitorDialog(UIUtils.getShell()); try { pm.run(true, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { INode root = parent.getRoot(); final String puri = parent instanceof MResource ? ((MResource) parent).getValue().getUriString() : ""; //$NON-NLS-1$ doWork(monitor, parent, list); ANode p = parent; if (parent instanceof MResource) p = new ModelVisitor<ANode>(root) { @Override public boolean visit(INode n) { if (n instanceof MResource) { MResource mres = (MResource) n; if (mres.getValue() != null && mres.getValue().getUriString().equals(puri)) { setObject(mres); stop(); } } return true; } }.getObject(); if (!p.getChildren().isEmpty()) p = (ANode) p.getChildren().get(0); s = new TreeSelection(new TreePath(new Object[] { p })); UIUtils.getDisplay().asyncExec(new Runnable() { public void run() { treeViewer.refresh(true); treeViewer.setSelection(s); } }); } catch (Throwable e) { throw new InvocationTargetException(e); } finally { monitor.done(); } } }); } catch (InvocationTargetException e) { UIUtils.showError(e.getCause()); } catch (InterruptedException e) { UIUtils.showError(e); } }
From source file:com.kixeye.chassis.transport.websocket.ActionInvokingWebSocket.java
public void onWebSocketError(Throwable cause) { logger.error("Unexpected socket error", cause); if (session.isOpen()) { try {//from w w w. j av a2 s .c o m String action = null; String txId = null; WebSocketServiceException serviceException = null; Throwable currentCause = cause; while (currentCause != null) { if (currentCause instanceof WebSocketServiceException) { serviceException = (WebSocketServiceException) currentCause; } currentCause = currentCause.getCause(); } if (serviceException != null) { action = serviceException.action; txId = serviceException.transactionId; } else { action = "UNKNOWN"; } sendMessage(action, txId, ExceptionServiceErrorMapper .mapException(serviceException == null ? cause : serviceException)).get(); } catch (Exception e) { logger.error("Unexpected error", e); } } }
From source file:it.geosolutions.opensdi2.userexpiring.ExpiringTask.java
/** * Check GeoStore Connection// w w w . j a v a 2 s . co m * * @param client * @return */ protected boolean pingGeoStore() { try { administratorGeoStoreClient.getCategories(); return true; } catch (Exception ex) { // ... and now for an awful example of heuristic..... Throwable t = ex; while (t != null) { if (t instanceof ConnectException) { LOGGER.warn("Testing GeoStore is offline"); return false; } t = t.getCause(); } return false; } }
From source file:hudson.Util.java
/** * Extracts the Win32 error message from {@link Throwable} if possible. * * @return//from ww w . j a va 2 s . c o m * null if there seems to be no error code or if the platform is not Win32. */ public static String getWin32ErrorMessage(Throwable e) { String msg = e.getMessage(); if (msg != null) { Matcher m = errorCodeParser.matcher(msg); if (m.matches()) { try { ResourceBundle rb = ResourceBundle.getBundle("/hudson/win32errors"); return rb.getString("error" + m.group(1)); } catch (Exception _) { // silently recover from resource related failures } } } if (e.getCause() != null) { return getWin32ErrorMessage(e.getCause()); } return null; // no message }