1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
package org.mule.example.errorhandler; |
8 | |
|
9 | |
import org.mule.api.MuleEventContext; |
10 | |
import org.mule.api.MuleException; |
11 | |
import org.mule.api.lifecycle.Callable; |
12 | |
import org.mule.util.StringMessageUtils; |
13 | |
|
14 | |
import java.util.ArrayList; |
15 | |
import java.util.List; |
16 | |
|
17 | |
import org.apache.commons.logging.Log; |
18 | |
import org.apache.commons.logging.LogFactory; |
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | 0 | public class BusinessErrorManager implements Callable |
26 | |
{ |
27 | |
|
28 | 0 | private static final Log logger = LogFactory.getLog(BusinessErrorManager.class); |
29 | |
|
30 | |
public Object onCall(MuleEventContext context) throws MuleException |
31 | |
{ |
32 | 0 | ErrorMessage msg = (ErrorMessage)context.getMessage().getPayload(); |
33 | |
|
34 | 0 | List<String> msgs = new ArrayList<String>(); |
35 | |
|
36 | 0 | msgs.add(LocaleMessage.businessErrorManagerError()); |
37 | 0 | msgs.add(LocaleMessage.errorDetail(msg.getException().getDetailMessage())); |
38 | 0 | msgs.add(LocaleMessage.errorClass(msg.getException().getClass())); |
39 | |
|
40 | 0 | logger.info("\n" + StringMessageUtils.getBoilerPlate(msgs, '*', 80)); |
41 | 0 | context.setStopFurtherProcessing(true); |
42 | 0 | return null; |
43 | |
} |
44 | |
|
45 | |
} |