View Javadoc
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.api.transport;
8   
9   import org.mule.api.MuleException;
10  import org.mule.api.endpoint.ImmutableEndpoint;
11  import org.mule.config.i18n.CoreMessages;
12  import org.mule.config.i18n.Message;
13  import org.mule.util.ObjectUtils;
14  
15  /**
16   * <code>ReceiveException</code> is specifically thrown by the Provider receive
17   * method if something fails in the underlying transport
18   */
19  public class ReceiveException extends MuleException
20  {
21      /**
22       * Serial version
23       */
24      private static final long serialVersionUID = 1960304517882133951L;
25  
26      private ImmutableEndpoint endpoint;
27  
28      /**
29       * @param message the exception message
30       */
31      public ReceiveException(Message message, ImmutableEndpoint endpoint, long timeout)
32      {
33          super(message);
34          this.endpoint = endpoint;
35          addInfo("Endpoint", ObjectUtils.toString(this.endpoint, "null"));
36          addInfo("Timeout", String.valueOf(timeout));
37      }
38  
39      /**
40       * @param message the exception message
41       * @param cause the exception that cause this exception to be thrown
42       */
43      public ReceiveException(Message message, ImmutableEndpoint endpoint, long timeout, Throwable cause)
44      {
45          super(message, cause);
46          this.endpoint = endpoint;
47          addInfo("Endpoint", ObjectUtils.toString(this.endpoint, "null"));
48          addInfo("Timeout", String.valueOf(timeout));
49      }
50  
51      public ReceiveException(ImmutableEndpoint endpoint, long timeout, Throwable cause)
52      {
53          this(CoreMessages.failedToRecevieWithTimeout(endpoint, timeout),
54              endpoint, timeout, cause);
55      }
56  }