Throwable cause = ex.getCause(); if (cause instanceof RuntimeException) { throw (RuntimeException)cause;
Throwable cause = ex.getCause(); if (cause instanceof RuntimeException) { throw (RuntimeException)cause;
private void updateCompletionCallbacks(Throwable error) { Throwable actualError = error instanceof Fault ? ((Fault)error).getCause() : error; for (CompletionCallback completionCallback : completionCallbacks) { completionCallback.onComplete(actualError); } }
@Override public void onError(Throwable error) { if (completionCallback != null) { Throwable actualError = error instanceof Fault ? ((Fault)error).getCause() : error; completionCallback.onError(actualError); } }
protected static void reportMessageHandlerProblem(String name, Class<?> cls, MediaType ct, Throwable ex) { String errorMessage = JAXRSUtils.logMessageHandlerProblem(name, cls, ct); Throwable actualEx = ex instanceof Fault ? ((Fault)ex).getCause() : ex; throw new ProcessingException(errorMessage, actualEx); }
protected static void reportMessageHandlerProblem(String name, Class<?> cls, MediaType ct, Throwable ex) { String errorMessage = JAXRSUtils.logMessageHandlerProblem(name, cls, ct); Throwable actualEx = ex instanceof Fault ? ((Fault)ex).getCause() : ex; throw new ProcessingException(errorMessage, actualEx); }
private Object handleAsyncFault(Exchange exchange, AsyncResponseImpl ar, Throwable t) { try { return handleFault(new Fault(t), exchange.getInMessage(), null, null); } catch (Fault ex) { ar.setUnmappedThrowable(ex.getCause() == null ? ex : ex.getCause()); if (isSuspended(exchange)) { ar.reset(); exchange.getInMessage().getInterceptorChain().unpause(); } return new MessageContentsList(Response.serverError().build()); } }
@Override public void handleMessage(SoapMessage message) throws Fault { Fault f = (Fault) message.getContent(Exception.class); if (f == null) { return; } Throwable cause = f.getCause(); if (cause == null) { return; } f.setStatusCode(HTTP_OK_CODE); if (isClientException(cause)) { f.setFaultCode(new QName("Client")); } }
protected static void reportMessageHandlerProblem(String name, Class<?> cls, MediaType ct, Throwable ex, Response response) { org.apache.cxf.common.i18n.Message errorMsg = new org.apache.cxf.common.i18n.Message(name, BUNDLE, cls, JAXRSUtils.mediaTypeToString(ct)); LOG.severe(errorMsg.toString()); Throwable actualEx = ex instanceof Fault ? ((Fault)ex).getCause() : ex; throw new ClientException(errorMsg.toString(), actualEx); }
public static XMLFault createFault(Fault f) { if (f instanceof XMLFault) { return (XMLFault) f; } Throwable th = f.getCause(); XMLFault xmlFault = new XMLFault(new Message(f.getMessage(), (ResourceBundle) null), th); xmlFault.setDetail(f.getDetail()); return xmlFault; }
public void handleMessage(Message message) throws Fault { Fault fault = (Fault)message.getContent(Exception.class); Throwable ex = fault.getCause(); if (!(ex instanceof SecurityException)) { throw new RuntimeException("Security Exception is expected"); } HttpServletResponse response = (HttpServletResponse)message.getExchange().getInMessage() .get(AbstractHTTPDestination.HTTP_RESPONSE); int status = ex instanceof AccessDeniedException ? 403 : 401; response.setStatus(status); try { response.getOutputStream().write(ex.getMessage().getBytes()); response.getOutputStream().flush(); } catch (IOException iex) { // ignore } message.getInterceptorChain().abort(); }
public static XMLFault createFault(Fault f) { if (f instanceof XMLFault) { return (XMLFault) f; } Throwable th = f.getCause(); XMLFault xmlFault = new XMLFault(new Message(f.getMessage(), (ResourceBundle) null), th); xmlFault.setDetail(f.getDetail()); return xmlFault; }
public static JbiFault createFault(Fault f) { if (f instanceof JbiFault) { return (JbiFault) f; } Throwable th = f.getCause(); JbiFault jbiFault = new JbiFault(new Message(f.getMessage(), (ResourceBundle) null), th); jbiFault.setDetail(f.getDetail()); return jbiFault; }
public static NMRFault createFault(Fault f) { if (f instanceof NMRFault) { return (NMRFault) f; } Throwable th = f.getCause(); NMRFault jbiFault = new NMRFault(new Message(f.getMessage(), (ResourceBundle) null), th); jbiFault.setDetail(f.getDetail()); return jbiFault; }
public static JBIFault createFault(Fault f) { if (f instanceof JBIFault) { return (JBIFault) f; } Throwable th = f.getCause(); JBIFault jbiFault = new JBIFault(new Message(f.getMessage(), (ResourceBundle) null), th); jbiFault.setDetail(f.getDetail()); return jbiFault; }
@Override public void handleMessage(SoapMessage soapMessage) throws Fault { Fault fault = (Fault) soapMessage.getContent(Exception.class); Throwable faultCause = fault.getCause(); String faultMessage = fault.getMessage(); if (containsFaultIndicatingNotSchemeCompliantXml(faultCause, faultMessage)) { LOG.schemaValidationError(FaultConst.SCHEME_VALIDATION_ERROR, faultMessage); WeatherSoapFaultHelper.buildWeatherFaultAndSet2SoapMessage(soapMessage, FaultConst.SCHEME_VALIDATION_ERROR); } else if (containsFaultIndicatingSyntacticallyIncorrectXml(faultCause)) { LOG.schemaValidationError(FaultConst.SYNTACTICALLY_INCORRECT_XML_ERROR, faultMessage); WeatherSoapFaultHelper.buildWeatherFaultAndSet2SoapMessage(soapMessage, FaultConst.SYNTACTICALLY_INCORRECT_XML_ERROR); } }
@Override public void handleMessage(SoapMessage soapMessage) throws Fault { Fault fault = (Fault) soapMessage.getContent(Exception.class); Throwable faultCause = fault.getCause(); String faultMessage = fault.getMessage(); if (containsFaultIndicatingNotSchemeCompliantXml(faultCause, faultMessage)) { LOG.schemaValidationError(FaultConst.SCHEME_VALIDATION_ERROR, faultMessage); WeatherSoapFaultHelper.buildWeatherFaultAndSet2SoapMessage(soapMessage, FaultConst.SCHEME_VALIDATION_ERROR); } else if (containsFaultIndicatingSyntacticallyIncorrectXml(faultCause)) { LOG.schemaValidationError(FaultConst.SYNTACTICALLY_INCORRECT_XML_ERROR, faultMessage); WeatherSoapFaultHelper.buildWeatherFaultAndSet2SoapMessage(soapMessage, FaultConst.SYNTACTICALLY_INCORRECT_XML_ERROR); } }
protected void checkClientException(Message outMessage, Exception ex) throws Exception { Throwable actualEx = ex instanceof Fault ? ((Fault)ex).getCause() : ex; Integer responseCode = getResponseCode(outMessage.getExchange()); if (responseCode == null || actualEx instanceof IOException && outMessage.getExchange().get("client.redirect.exception") != null) { if (actualEx instanceof ClientException) { throw ex; } else if (actualEx != null) { throw new ClientException(actualEx); } else if (!outMessage.getExchange().isOneWay() || cfg.isResponseExpectedForOneway()) { waitForResponseCode(outMessage.getExchange()); } } }
@Override public void handleMessage(SoapMessage soapMessage) throws Fault { Fault fault = (Fault) soapMessage.getContent(Exception.class); Throwable faultCause = fault.getCause(); String faultMessage = fault.getMessage(); if (containsFaultIndicatingNotSchemeCompliantXml(faultCause, faultMessage)) { LOG.schemaValidationError(FaultType.SCHEME_VALIDATION_ERROR, faultMessage); soapFaultBuilder.buildCustomFaultAndSet2SoapMessage(soapMessage, FaultType.SCHEME_VALIDATION_ERROR); } else if (containsFaultIndicatingSyntacticallyIncorrectXml(faultCause)) { LOG.schemaValidationError(FaultType.SYNTACTICALLY_INCORRECT_XML_ERROR, faultMessage); soapFaultBuilder.buildCustomFaultAndSet2SoapMessage(soapMessage, FaultType.SYNTACTICALLY_INCORRECT_XML_ERROR); } else if(someOtherErrorOccured(faultCause)) { // Some other Error occured, we don´t know. But we want to react with a Custom Error-Message LOG.errorOccuredInBackendProcessing(faultCause); soapFaultBuilder.buildCustomFaultAndSet2SoapMessage(soapMessage, FaultType.BACKEND_PROCESSING_FAILED); } }