Coverage Report - org.mule.transport.jms.JmsExceptionReader
 
Classes in this File Line Coverage Branch Coverage Complexity
JmsExceptionReader
0%
0/13
0%
0/2
0
 
 1  
 /*
 2  
  * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 3  
  * The software in this package is published under the terms of the CPAL v1.0
 4  
  * license, a copy of which has been included with this distribution in the
 5  
  * LICENSE.txt file.
 6  
  */
 7  
 package org.mule.transport.jms;
 8  
 
 9  
 import org.mule.api.config.ExceptionReader;
 10  
 
 11  
 import java.util.HashMap;
 12  
 import java.util.Map;
 13  
 
 14  
 import javax.jms.JMSException;
 15  
 
 16  
 /**
 17  
  * This reader will ensure that the LinkedException and JMS code is not lost when
 18  
  * printing the JMSException.
 19  
  */
 20  0
 public class JmsExceptionReader implements ExceptionReader
 21  
 {
 22  
 
 23  
     public String getMessage(Throwable t)
 24  
     {
 25  0
         JMSException e = (JMSException)t;
 26  0
         return e.getMessage() + "(JMS Code: " + e.getErrorCode() + ")";
 27  
     }
 28  
 
 29  
     public Throwable getCause(Throwable t)
 30  
     {
 31  0
         JMSException e = (JMSException)t;
 32  0
         Throwable cause = e.getLinkedException();
 33  0
         if (cause == null)
 34  
         {
 35  0
             cause = e.getCause();
 36  
         }
 37  0
         return cause;
 38  
     }
 39  
 
 40  
     public Class<?> getExceptionType()
 41  
     {
 42  0
         return JMSException.class;
 43  
     }
 44  
 
 45  
     /**
 46  
      * Returns a map of the non-stanard information stored on the exception
 47  
      * 
 48  
      * @return a map of the non-stanard information stored on the exception
 49  
      */
 50  
     public Map<?, ?> getInfo(Throwable t)
 51  
     {
 52  0
         JMSException e = (JMSException)t;
 53  0
         Map<String, Object> info = new HashMap<String, Object>();
 54  0
         info.put("JMS Code", e.getErrorCode());
 55  0
         return info;
 56  
     }
 57  
 
 58  
 }