javax.ws.rs.client
Class InvocationException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by javax.ws.rs.client.ClientException
                  extended by javax.ws.rs.client.InvocationException
All Implemented Interfaces:
Serializable

public class InvocationException
extends ClientException

A runtime exception thrown during the HTTP request invocation processing, that signals a failure to process the HTTP request or response. The exception message or nested Throwable cause SHOULD contain additional information about the reason of the processing failure. The exception is also thrown when the status code of the returned HTTP response indicates a response that is not expected.

This exception is typically thrown by the HTTP invocation methods on an Invocation or a Client instance. Additionally, the exception is also thrown by Response readEntity(...) methods in case the returned response is HTTP 204 (No Content).

Whenever the exception is thrown in the context of an existing response, the response will be referenced by the exception.

Since:
2.0
Author:
Marek Potociar
See Also:
Serialized Form

Constructor Summary
InvocationException(Response response)
          Construct a client-side invocation exception and set the exception's response reference to point to the provided response input parameter.
InvocationException(Response response, boolean bufferResponseEntity)
          Construct a client-side invocation exception and set the exception's response reference to point to the provided response input parameter.
InvocationException(String message)
          Construct a client-side invocation exception without a response.
InvocationException(String message, Response response)
          Construct a client-side invocation exception and set the exception's response reference to point to the provided response input parameter.
InvocationException(String message, Response response, boolean bufferResponseEntity)
          Construct a client-side invocation exception and set the exception's response reference to point to the provided response input parameter.
InvocationException(String message, Throwable cause)
          Constructs a new client-side invocation exception with the specified detail message and cause.
 
Method Summary
 Response getResponse()
          Get the client response associated with the exception.
 String toString()
           
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

InvocationException

public InvocationException(String message)
Construct a client-side invocation exception without a response.

The client response wrapped by the exception will be set to null.

Parameters:
message - the message of the exception.

InvocationException

public InvocationException(String message,
                           Throwable cause)
Constructs a new client-side invocation exception with the specified detail message and cause. The nested response reference will be set to null.

Note that the detail message associated with cause is not automatically incorporated in this runtime exception's detail message.

Parameters:
message - the detail message (which is saved for later retrieval by the Throwable.getMessage() method).
cause - the cause (which is saved for later retrieval by the Throwable.getCause() method). (A null value is permitted, and indicates that the cause is nonexistent or unknown.)

InvocationException

public InvocationException(Response response)
Construct a client-side invocation exception and set the exception's response reference to point to the provided response input parameter. The message of the exception is set to a value returned by response.toString().

The entity of the referenced response will be buffered.

Parameters:
response - the client response. The message of the exception is set to a value returned by response.toString().

InvocationException

public InvocationException(Response response,
                           boolean bufferResponseEntity)
Construct a client-side invocation exception and set the exception's response reference to point to the provided response input parameter. The message of the exception is set to a value returned by response.toString().

The entity of the referenced response will be buffered if the bufferResponseEntity is set to true.

Parameters:
response - the client response. The message of the exception is set to a value returned by response.toString().
bufferResponseEntity - if true the entity of the referenced response will be buffered.

InvocationException

public InvocationException(String message,
                           Response response)
Construct a client-side invocation exception and set the exception's response reference to point to the provided response input parameter. The message of the exception is set to a value of message input parameter.

The entity of the referenced response will be buffered.

Parameters:
message - the detail message (which is saved for later retrieval by the Throwable.getMessage() method).
response - the client response. The message of the exception is set to a value returned by response.toString().

InvocationException

public InvocationException(String message,
                           Response response,
                           boolean bufferResponseEntity)
Construct a client-side invocation exception and set the exception's response reference to point to the provided response input parameter. The message of the exception is set to a value of message input parameter.

The entity of the referenced response will be buffered if the bufferResponseEntity is set to true.

Parameters:
message - the detail message (which is saved for later retrieval by the Throwable.getMessage() method).
response - the client response. The message of the exception is set to a value returned by response.toString().
bufferResponseEntity - if true the entity of the referenced response will be buffered.
Method Detail

getResponse

public Response getResponse()
Get the client response associated with the exception. May return null if the exception was not associated with any particular response.

Returns:
the client response if set, otherwise null.

toString

public String toString()
Overrides:
toString in class Throwable


Copyright © 2007-2012 Oracle Corporation. All Rights Reserved. Use is subject to license terms.