List of usage examples for java.lang Throwable getCause
public synchronized Throwable getCause()
From source file:com.orange.mmp.api.ws.rest.RestResponse.java
/** * Generate error code and error message from a Throwable * /*from w ww.ja va2s .com*/ * @param e Throwable instance linked to the error */ protected void parseThrowable(Throwable e) { int currentLevel = 0; Throwable ref = e; while (currentLevel++ < MAX_RECURSIVE_SEARCH && ref.getMessage() == null && ref.getCause() != null) { ref = ref.getCause(); } this.responseContext.sendError(DEFAULT_ERROR_CODE, (ref.getMessage() == null) ? DEFAULT_ERROR_MESSAGE : ref.getMessage()); }
From source file:dk.itst.oiosaml.sp.service.LogoutServiceSOAPHandler.java
/** * Receive and handle a <LogoutRequest> from the Login Site * @throws IOException // w w w . ja v a2s. co m */ public void handlePost(RequestContext ctx) throws ServletException, IOException { String statusCode = StatusCode.SUCCESS_URI; String consent = null; OIOLogoutRequest logoutRequest = extractRequest(ctx.getRequest()); Audit.log(Operation.LOGOUT_SOAP, false, logoutRequest.getID(), logoutRequest.toXML()); try { String sessionIndex = logoutRequest.getSessionIndex(); String sessionId = ctx.getSessionHandler().getRelatedSessionId(sessionIndex); OIOAssertion assertion = ctx.getSessionHandler().getAssertion(sessionId); String idpEntityId = null; if (assertion != null) { idpEntityId = assertion.getIssuer(); } if (idpEntityId == null) { log.warn("LogoutRequest received over SOAP for unknown user"); statusCode = StatusCode.NO_SUPPORTED_IDP_URI; } else { try { Metadata metadata = ctx.getIdpMetadata().getMetadata(idpEntityId); logoutRequest.validateRequest(null, null, metadata.getPublicKeys(), ctx.getSpMetadata().getSingleLogoutServiceSOAPLocation(), metadata.getEntityID()); ctx.getSessionHandler().logOut(sessionId); Audit.log(Operation.LOGOUT, assertion.getSubjectNameIDValue()); } catch (LogoutRequestValidationException e) { consent = e.getMessage(); statusCode = StatusCode.AUTHN_FAILED_URI; } } } catch (Throwable t) { statusCode = StatusCode.AUTHN_FAILED_URI; consent = t instanceof WrappedException ? t.getCause().getMessage() : t.getMessage(); Audit.logError(Operation.LOGOUT_SOAP, false, logoutRequest.getID(), t); } if (log.isDebugEnabled()) log.debug("Logout status: " + statusCode + ", message: " + consent); OIOLogoutResponse logoutResponse = OIOLogoutResponse.fromRequest(logoutRequest, statusCode, consent, ctx.getSpMetadata().getEntityID(), null); returnResponse(ctx.getResponse(), logoutResponse, ctx.getCredential()); Audit.log(Operation.LOGOUT_SOAP, true, logoutRequest.getID(), logoutResponse.toXML()); }
From source file:de.metas.ui.web.config.WebuiExceptionHandler.java
private void addErrorDetails(final Map<String, Object> errorAttributes, final RequestAttributes requestAttributes, final boolean includeStackTrace) { Throwable error = getError(requestAttributes); if (error != null) { while (error instanceof ServletException && error.getCause() != null) { error = ((ServletException) error).getCause(); }/*www . j a v a 2s. co m*/ errorAttributes.put(ATTR_Exception, error.getClass().getName()); addErrorMessage(errorAttributes, error); if (includeStackTrace && !isExcludeFromLogging(error)) { addStackTrace(errorAttributes, error); } } final Object message = getAttribute(requestAttributes, RequestDispatcher.ERROR_MESSAGE); if ((!StringUtils.isEmpty(message) || errorAttributes.get(ATTR_Message) == null) && !(error instanceof BindingResult)) { errorAttributes.put(ATTR_Message, StringUtils.isEmpty(message) ? "No message available" : message); } }
From source file:com.reversemind.hypergate.integration.ejb.client.AbstractClientEJB.java
@Override public <T> T getProxy(Class<T> interfaceClass) throws Exception { if (clientPool == null) { this.clientFullReconnect(); if (clientPool == null) { throw new Exception("HyperGate client is not running"); }/*from w w w. j a v a2s . co m*/ } if (this.proxyFactoryPool == null) { this.clientFullReconnect(); if (this.proxyFactoryPool == null) { throw new Exception("Could not get proxyFactory for " + interfaceClass); } } T object = null; try { LOG.info("Going to create new newProxyInstance from proxyFactory" + this.proxyFactoryPool); LOG.info("Client pool is:" + clientPool); //object = (T)this.proxyFactory.newProxyInstance(interfaceClass); object = (T) this.proxyFactoryPool.newProxyInstance(this.clientPool, interfaceClass); } catch (Throwable th) { // com.reversemind.hypergate.proxy.ProxySendException: =HyperGate= Could not to send data into server: - let's reconnect Throwable throwableLocal = th.getCause(); LOG.warn("some troubles with sending data to the server let's reconnect"); if (throwableLocal.getClass().equals(ProxySendException.class)) { LOG.info("detected ProxySendException:" + throwableLocal.getMessage()); this.clientFullReconnect(); //object = (T)this.proxyFactory.newProxyInstance(interfaceClass); LOG.info("Client pool is:" + clientPool); object = (T) this.proxyFactoryPool.newProxyInstance(this.clientPool, interfaceClass); } if (throwableLocal.getCause().getClass().equals(Exception.class)) { throw new Exception("Could not to get proxy or send data to server"); } } return object; }
From source file:com.haulmont.cuba.gui.exception.UniqueConstraintViolationHandler.java
@Override public boolean handle(Throwable exception, WindowManager windowManager) { Throwable t = exception; try {/*from www . j av a 2 s .c o m*/ while (t != null) { if (t.toString().contains("org.eclipse.persistence.exceptions.DatabaseException")) { return doHandle(t, windowManager); } t = t.getCause(); } return false; } catch (Exception e) { return false; } }
From source file:fedora.server.security.servletfilters.Cache.java
public final Map getNamedValues(CacheElementPopulator authenticator, String userid, String password) throws Throwable { if (firstCall) { testAssert();//from w w w. jav a2 s. co m firstCall = false; } String m = getCacheAbbrev() + " getNamedValues() "; if (LOG.isDebugEnabled()) { LOG.debug(m + "----------------------------------------------"); LOG.debug(m + "> " + getCacheId() + " [" + userid + "] [" + password + "]"); } CacheElement cacheElement = getCacheElement(userid /* , password */); LOG.debug(m + "cacheElement==" + cacheElement.getInstanceId()); Map namedValues = null; try { namedValues = cacheElement.getNamedValues(this, password); } catch (Throwable t) { LOG.fatal(m + ".authenticate"); LOG.fatal(m + t.getMessage()); LOG.fatal(m + (t.getCause() == null ? "" : t.getCause().getMessage())); throw t; } LOG.debug(m + "< " + namedValues); return namedValues; }
From source file:com.github.lynxdb.server.api.http.ErrorResponse.java
private void parseException(Throwable _thrw, StringBuilder _builder) { _builder.append(_thrw.getClass().getName()).append(": ").append(_thrw.getMessage()); for (StackTraceElement ste : _thrw.getStackTrace()) { _builder.append("\t").append(ste.toString()).append("\n"); }/*from w w w . j ava2s. c om*/ if (_thrw.getCause() != null) { _builder.append("Caused by :"); parseException(_thrw.getCause(), _builder); } }
From source file:com.taobao.adfs.util.Utilities.java
public static Throwable getFirstCause(Throwable t) { if (t == null) return null; while (t.getCause() != null && t.getCause() != t) { t = t.getCause();//from w w w . jav a2 s .co m } return t; }
From source file:fedora.server.security.servletfilters.Cache.java
public final Boolean authenticate(CacheElementPopulator authenticator, String userid, String password) throws Throwable { if (firstCall) { testAssert();/*from w ww. j a va 2 s.c o m*/ firstCall = false; } String m = getCacheAbbrev() + " authenticate() "; if (LOG.isDebugEnabled()) { LOG.debug(m + "----------------------------------------------"); LOG.debug(m + "> " + getCacheId() + " [" + userid + "] [" + password + "]"); } else { LOG.info("Authenticating user [" + userid + "]"); } CacheElement cacheElement = getCacheElement(userid /* , password */); LOG.debug(m + "cacheElement==" + cacheElement.getInstanceId()); Boolean authenticated = null; try { authenticated = cacheElement.authenticate(this, password); } catch (Throwable t) { LOG.fatal(m + ".authenticate() catch"); LOG.fatal(m + t.getMessage()); LOG.fatal(m + (t.getCause() == null ? "" : t.getCause().getMessage())); throw t; } LOG.debug(m + "< " + authenticated); return authenticated; }
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 // }//from ww w .j a v a2s. 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(); } } }