1
2
3
4
5
6
7
8
9
10
11 package org.mule.impl;
12
13 import org.mule.impl.message.ExceptionPayload;
14 import org.mule.providers.NullPayload;
15 import org.mule.umo.UMOMessage;
16 import org.mule.umo.endpoint.UMOImmutableEndpoint;
17 import org.mule.util.ObjectUtils;
18
19
20
21
22
23
24
25 public class DefaultExceptionStrategy extends AbstractExceptionListener
26 {
27 public void handleMessagingException(UMOMessage message, Throwable t)
28 {
29 defaultHandler(t);
30 routeException(message, null, t);
31 }
32
33 public void handleRoutingException(UMOMessage message, UMOImmutableEndpoint endpoint, Throwable t)
34 {
35 defaultHandler(t);
36 routeException(message, endpoint, t);
37 }
38
39 public void handleLifecycleException(Object component, Throwable t)
40 {
41
42
43 handleStandardException(t);
44 logger.error("The object that failed was: \n" + ObjectUtils.toString(component, "null"));
45 }
46
47 public void handleStandardException(Throwable t)
48 {
49 markTransactionForRollback();
50
51 if (RequestContext.getEventContext() != null)
52 {
53 handleMessagingException(RequestContext.getEventContext().getMessage(), t);
54 }
55 else
56 {
57 logger.info("There is no current event available, routing Null message with the exception");
58 handleMessagingException(new MuleMessage(NullPayload.getInstance()), t);
59 }
60 }
61
62 protected void defaultHandler(Throwable t)
63 {
64 logException(t);
65 if (RequestContext.getEvent() != null)
66 {
67 RequestContext.setExceptionPayload(new ExceptionPayload(t));
68 }
69 }
70 }