View Javadoc

1   /*
2    * $Id: ReceiveException.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.api.transport;
12  
13  import org.mule.api.MuleException;
14  import org.mule.api.endpoint.ImmutableEndpoint;
15  import org.mule.config.i18n.CoreMessages;
16  import org.mule.config.i18n.Message;
17  import org.mule.util.ObjectUtils;
18  
19  /**
20   * <code>ReceiveException</code> is specifically thrown by the Provider receive
21   * method if something fails in the underlying transport
22   */
23  public class ReceiveException extends MuleException
24  {
25      /**
26       * Serial version
27       */
28      private static final long serialVersionUID = 1960304517882133951L;
29  
30      private ImmutableEndpoint endpoint;
31  
32      /**
33       * @param message the exception message
34       */
35      public ReceiveException(Message message, ImmutableEndpoint endpoint, long timeout)
36      {
37          super(message);
38          this.endpoint = endpoint;
39          addInfo("Endpoint", ObjectUtils.toString(this.endpoint, "null"));
40          addInfo("Timeout", String.valueOf(timeout));
41      }
42  
43      /**
44       * @param message the exception message
45       * @param cause the exception that cause this exception to be thrown
46       */
47      public ReceiveException(Message message, ImmutableEndpoint endpoint, long timeout, Throwable cause)
48      {
49          super(message, cause);
50          this.endpoint = endpoint;
51          addInfo("Endpoint", ObjectUtils.toString(this.endpoint, "null"));
52          addInfo("Timeout", String.valueOf(timeout));
53      }
54  
55      public ReceiveException(ImmutableEndpoint endpoint, long timeout, Throwable cause)
56      {
57          this(CoreMessages.failedToRecevieWithTimeout(endpoint, timeout),
58              endpoint, timeout, cause);
59      }
60  }