/** * Convenience method to get the vendor specific error code if * the root cause was an instance of JMSException. * @return a string specifying the vendor-specific error code if the * root cause is an instance of JMSException, or {@code null} */ @Nullable public String getErrorCode() { Throwable cause = getCause(); if (cause instanceof JMSException) { return ((JMSException) cause).getErrorCode(); } return null; }
/** * Return the detail message, including the message from the linked exception * if there is one. * @see javax.jms.JMSException#getLinkedException() */ @Override @Nullable public String getMessage() { String message = super.getMessage(); Throwable cause = getCause(); if (cause instanceof JMSException) { Exception linkedEx = ((JMSException) cause).getLinkedException(); if (linkedEx != null) { String linkedMessage = linkedEx.getMessage(); String causeMessage = cause.getMessage(); if (linkedMessage != null && (causeMessage == null || !causeMessage.contains(linkedMessage))) { message = message + "; nested exception is " + linkedEx; } } } return message; }
protected void doTestJmsException(JMSException original, Class<? extends JmsException> thrownExceptionClass) throws Exception { JmsTemplate template = createTemplate(); template.setConnectionFactory(this.connectionFactory); template.setMessageConverter(new SimpleMessageConverter()); String s = "Hello world"; MessageProducer messageProducer = mock(MessageProducer.class); TextMessage textMessage = mock(TextMessage.class); reset(this.session); given(this.session.createProducer(this.queue)).willReturn(messageProducer); given(this.session.createTextMessage("Hello world")).willReturn(textMessage); willThrow(original).given(messageProducer).send(textMessage); try { template.convertAndSend(this.queue, s); fail("Should have thrown JmsException"); } catch (JmsException wrappedEx) { // expected assertEquals(thrownExceptionClass, wrappedEx.getClass()); assertEquals(original, wrappedEx.getCause()); } verify(messageProducer).close(); verify(this.session).close(); verify(this.connection).close(); }
/** * Convenience method to get the vendor specific error code if * the root cause was an instance of JMSException. * @return a string specifying the vendor-specific error code if the * root cause is an instance of JMSException, or {@code null} */ public String getErrorCode() { Throwable cause = getCause(); if (cause instanceof JMSException) { return ((JMSException) cause).getErrorCode(); } return null; }
/** * Convenience method to get the vendor specific error code if * the root cause was an instance of JMSException. * @return a string specifying the vendor-specific error code if the * root cause is an instance of JMSException, or {@code null} */ public String getErrorCode() { Throwable cause = getCause(); if (cause instanceof JMSException) { return ((JMSException) cause).getErrorCode(); } return null; }
/** * Convenience method to get the vendor specific error code if * the root cause was an instance of JMSException. * @return a string specifying the vendor-specific error code if the * root cause is an instance of JMSException, or {@code null} */ @Nullable public String getErrorCode() { Throwable cause = getCause(); if (cause instanceof JMSException) { return ((JMSException) cause).getErrorCode(); } return null; }
/** * Return the detail message, including the message from the linked exception * if there is one. * @see javax.jms.JMSException#getLinkedException() */ public String getMessage() { String message = super.getMessage(); Throwable cause = getCause(); if (cause instanceof JMSException) { Exception linkedEx = ((JMSException) cause).getLinkedException(); if (linkedEx != null) { String linkedMessage = linkedEx.getMessage(); String causeMessage = cause.getMessage(); if (linkedMessage != null && (causeMessage == null || !causeMessage.contains(linkedMessage))) { message = message + "; nested exception is " + linkedEx; } } } return message; }
/** * Return the detail message, including the message from the linked exception * if there is one. * @see javax.jms.JMSException#getLinkedException() */ @Override @Nullable public String getMessage() { String message = super.getMessage(); Throwable cause = getCause(); if (cause instanceof JMSException) { Exception linkedEx = ((JMSException) cause).getLinkedException(); if (linkedEx != null) { String linkedMessage = linkedEx.getMessage(); String causeMessage = cause.getMessage(); if (linkedMessage != null && (causeMessage == null || !causeMessage.contains(linkedMessage))) { message = message + "; nested exception is " + linkedEx; } } } return message; }
/** * Return the detail message, including the message from the linked exception * if there is one. * @see javax.jms.JMSException#getLinkedException() */ @Override public String getMessage() { String message = super.getMessage(); Throwable cause = getCause(); if (cause instanceof JMSException) { Exception linkedEx = ((JMSException) cause).getLinkedException(); if (linkedEx != null) { String linkedMessage = linkedEx.getMessage(); String causeMessage = cause.getMessage(); if (linkedMessage != null && (causeMessage == null || !causeMessage.contains(linkedMessage))) { message = message + "; nested exception is " + linkedEx; } } } return message; }