KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > providers > jms > JmsExceptionReader


1 /*
2  * $Id: JmsExceptionReader.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.providers.jms;
12
13 import java.util.HashMap JavaDoc;
14 import java.util.Map JavaDoc;
15
16 import javax.jms.JMSException JavaDoc;
17
18 import org.mule.config.ExceptionReader;
19
20 /**
21  * This reader will ensure that the LinkedException and JMS code is not lost when
22  * printing the JMSException.
23  */

24 public class JmsExceptionReader implements ExceptionReader
25 {
26
27     public String JavaDoc getMessage(Throwable JavaDoc t)
28     {
29         JMSException JavaDoc e = (JMSException JavaDoc)t;
30         return e.getMessage() + "(JMS Code: " + e.getErrorCode() + ")";
31     }
32
33     public Throwable JavaDoc getCause(Throwable JavaDoc t)
34     {
35         JMSException JavaDoc e = (JMSException JavaDoc)t;
36         Throwable JavaDoc cause = e.getLinkedException();
37         if (cause == null)
38         {
39             cause = e.getCause();
40         }
41         return cause;
42     }
43
44     public Class JavaDoc getExceptionType()
45     {
46         return JMSException JavaDoc.class;
47     }
48
49     /**
50      * Returns a map of the non-stanard information stored on the exception
51      *
52      * @return a map of the non-stanard information stored on the exception
53      */

54     public Map JavaDoc getInfo(Throwable JavaDoc t)
55     {
56         JMSException JavaDoc e = (JMSException JavaDoc)t;
57         Map JavaDoc info = new HashMap JavaDoc();
58         info.put("JMS Code", e.getErrorCode());
59         return info;
60     }
61
62 }
63
Popular Tags