protected MessagingException filterFailureException(MuleEvent event, Exception ex) { return new MessagingException(event, ex, this); }
@Override public void processExceptionReplyTo(MessagingException exception, Object replyTo) { MuleEvent result; if (messagingExceptionHandler != null) { result = messagingExceptionHandler.handleException(exception, exception.getEvent()); } else { result = exception.getEvent().getFlowConstruct().getExceptionListener().handleException(exception, exception.getEvent()); } exception.setProcessedEvent(result); if (!exception.handled()) { delegate.processExceptionReplyTo(exception, replyTo); } else { try { delegate.processReplyTo(exception.getEvent(), exception.getEvent().getMessage(), replyTo); } catch (MuleException e) { delegate.processExceptionReplyTo(new MessagingException(exception.getEvent(), e), replyTo); } } } }
@Override public void sendFailureResponseToClient(MessagingException messagingException) throws MuleException { try { int statusCode = retrieveStatusCode(messagingException); servletResponseWriter.writeErrorResponse(servletResponse, messagingException.getEvent().getMessage(), statusCode, messagingException.getMessage(), httpThrottlingHeadersMapBuilder.build()); } catch (Exception e) { throw new DefaultMuleException(e); } failureResponseSentToClient = true; }
@Override public void processExceptionReplyTo(MessagingException exception, Object replyTo) { exception.setProcessedEvent(createReturnEventForParentFlowConstruct(exception.getEvent(), event)); replyToHandler.processExceptionReplyTo(exception, null); } }, getExceptionListener());
@Override protected MessagingException filterFailureException(MuleEvent event, Exception ex) { MessagingException messagingException = new MessagingException(event, ex, this); String docName = LocationExecutionContextProvider.getDocName(filter); messagingException.getInfo().put("Filter", docName != null ? String.format("%s (%s)", filter.toString(), docName) : filter.toString()); return messagingException; }
return event; } catch (MessagingException messagingException) { messagingException.setProcessedEvent(event); throw messagingException; } catch (Exception e) { throw new MessagingException(CoreMessages.failedToInvoke("addWorkdayAccount"), event, e);
protected void doProcess(MuleEvent event) throws MuleException, MessagingException { try { ownedMessageProcessor.process(event); } catch (MessagingException e) { if (splitter.equals(e.getFailingMessageProcessor()) || filter.equals(e.getFailingMessageProcessor())) { // Make sure the context information for the exception is relative to the ForEach. e.getInfo().remove(INFO_LOCATION_KEY); throw new MessagingException(event, e, this); } else { throw e; } } }
/** * @deprecated use {@link #getEvent().getMessage()} instead */ @Deprecated public MuleMessage getMuleMessage() { if ((getEvent() != null)) { return event.getMessage(); } return muleMessage; }
@Override public MuleEvent execute(MessageProcessor messageProcessor, MuleEvent event) throws MessagingException { try { return messageProcessor.process(event); } catch (MessagingException messagingException) { if (messagingException.getFailingMessageProcessor() == null) { throw putContext(messagingException, messageProcessor, event); } else { throw putContext(messagingException, messagingException.getFailingMessageProcessor(), event); } } catch (Throwable ex) { throw putContext(new MessagingException(event, ex, messageProcessor), messageProcessor, event); } }
@Override protected MuleEvent processCatch(MuleEvent event, MessagingException exception) throws MessagingException { ((ThreadSafeAccess) eventToEnrich).resetAccessControl(); OptimizedRequestContext.unsafeSetEvent(eventToEnrich); exception.setProcessedEvent(eventToEnrich); return super.processCatch(event, exception); }
return event; } catch (MessagingException messagingException) { messagingException.setProcessedEvent(event); throw messagingException; } catch (Exception e) { throw new MessagingException(CoreMessages.failedToInvoke("getCertificationIssuers"), event, e);
private void sendFailureResponseIfNeccessary(MessagingException messagingException, FlowProcessingPhaseTemplate flowProcessingPhaseTemplate) throws MuleException { if (flowProcessingPhaseTemplate instanceof RequestResponseFlowProcessingPhaseTemplate) { fireNotification(messagingException.getEvent(), MESSAGE_ERROR_RESPONSE); ((RequestResponseFlowProcessingPhaseTemplate) flowProcessingPhaseTemplate).sendFailureResponseToClient(messagingException); } }
@Override public MuleEvent execute(ExecutionCallback<MuleEvent> callback, ExecutionContext executionContext) throws Exception { try { return next.execute(callback, executionContext); } catch (MessagingException e) { MuleEvent result; if (messagingExceptionHandler != null) { result = messagingExceptionHandler.handleException(e, e.getEvent()); } else { result = e.getEvent().getFlowConstruct().getExceptionListener().handleException(e,e.getEvent()); } e.setProcessedEvent(result); throw e; } catch (Exception e) { throw e; } } }
return event; } catch (MessagingException messagingException) { messagingException.setProcessedEvent(event); throw messagingException; } catch (Exception e) { throw new MessagingException(CoreMessages.failedToInvoke("getCertificationIssuersTalent"), event, e);
private void handleException(MuleEvent event, Throwable e) throws MuleException { throw new MessagingException(CoreMessages.failedToInvoke(this.operationName), event, e); }
protected void handleException(Throwable exception, String message, HttpServletResponse response) { logger.error("message: " + exception.getMessage(), exception); int code = Integer.valueOf(ExceptionHelper.getErrorMapping("http", exception.getClass(),muleContext)); response.setStatus(code); try { String errorMessage = message + ": " + exception.getMessage(); if (exception instanceof MessagingException && ((MessagingException) exception).getEvent() != null) { MessagingException me = (MessagingException) exception; writeErrorResponseFromMessage(response, me.getEvent().getMessage(), code, errorMessage); } else { response.sendError(code, errorMessage); } } catch (Exception e) { logger.error("Failed to sendError on response: " + e.getMessage(), e); } }
@Override public MuleEvent process(final MuleEvent event) throws MuleException { final MuleEvent newEvent = createMuleEventForCurrentFlow(event, event.getReplyToDestination(), event.getReplyToHandler()); try { ExecutionTemplate<MuleEvent> executionTemplate = ErrorHandlingExecutionTemplate.createErrorHandlingExecutionTemplate(muleContext, getExceptionListener()); MuleEvent result = executionTemplate.execute(new ExecutionCallback<MuleEvent>() { @Override public MuleEvent process() throws Exception { return pipeline.process(newEvent); } }); return createReturnEventForParentFlowConstruct(result, event); } catch (MessagingException e) { e.setProcessedEvent(createReturnEventForParentFlowConstruct(e.getEvent(), event)); throw e; } catch (Exception e) { resetRequestContextEvent(event); throw new DefaultMuleException(CoreMessages.createStaticMessage("Flow execution exception"),e); } }
@Override public void sendFailureResponseToClient(MessagingException messagingException, ResponseCompletionCallback responseCompletationCallback) throws MuleException { //For now let's use the HTTP transport exception mapping since makes sense and the gateway depends on it. String exceptionStatusCode = ExceptionHelper.getTransportErrorMapping(HTTP.getScheme(), messagingException.getClass(), sourceMuleEvent.getMuleContext()); Integer statusCodeFromException = exceptionStatusCode != null ? Integer.valueOf(exceptionStatusCode) : INTERNAL_SERVER_ERROR_STATUS_CODE; final org.mule.module.http.internal.domain.response.HttpResponseBuilder failureResponseBuilder = new org.mule.module.http.internal.domain.response.HttpResponseBuilder() .setStatusCode(statusCodeFromException) .setReasonPhrase(messagingException.getMessage()); addThrottlingHeaders(failureResponseBuilder); MuleEvent event = messagingException.getEvent(); event.getMessage().setPayload(messagingException.getMessage()); final HttpResponse response = errorResponseBuilder.build(failureResponseBuilder, event); responseReadyCallback.responseReady(response, getResponseFailureCallback(responseCompletationCallback, messagingException.getEvent())); }
return event; } catch (MessagingException messagingException) { messagingException.setProcessedEvent(event); throw messagingException; } catch (Exception e) { throw new MessagingException(CoreMessages.failedToInvoke("getAbsenceInputs"), event, e);