com.ibm.as400.resource
Class ResourceException

java.lang.Object
  |
  +--java.lang.Throwable
        |
        +--java.lang.Exception
              |
              +--com.ibm.as400.resource.ResourceException
All Implemented Interfaces:
ReturnCodeException, java.io.Serializable

public class ResourceException
extends java.lang.Exception
implements ReturnCodeException

The ResourceException class represents an exception that occurs when using a Resource or ResourceList. Most of the time, this exception is thrown as the result of another exception being caught. In this case, the underlying exception is available here.

In some cases, the exception is expected by the user. For example, if the user explicitly canceled an operation, then the user expects the resulting exception. The default is that the exception is not expected by the user.

See Also:
Serialized Form

Field Summary
static int ATTRIBUTE_READ_ONLY
          The return code indicating that the resource attribute is read-only.
static int ATTRIBUTES_NOT_RETURNED
          The return code indicating that resource attributes were not returned.
static int ATTRIBUTES_NOT_SET
          The return code indicating that resource attributes were not set.
static int AUTHORITY_INSUFFICIENT
          The return code indicating that user has insuffient authority.
static int MESSAGES_RETURNED
          The return code indicating that AS/400 messages were returned.
static int OPERATION_FAILED
          The return code indicating that an operation failed.
static int OPERATION_NOT_SUPPORTED
          The return code indicating that an operation is not supported.
static int UNKNOWN_ERROR
          The return code indicating that an unknown problem has occurred.
 
Constructor Summary
ResourceException()
          Constructs a ResourceException object.
ResourceException(AS400Message[] messageList)
          Constructs a ResourceException object.
ResourceException(int returnCode)
          Constructs a ResourceException object.
ResourceException(int returnCode, java.lang.Throwable exception)
          Constructs a ResourceException object.
ResourceException(int returnCode, java.lang.Throwable exception, boolean expected)
          Constructs a ResourceException object.
ResourceException(java.lang.Throwable exception)
          Constructs a ResourceException object.
 
Method Summary
 java.lang.Throwable getException()
          Returns the underlying exception, if any.
 AS400Message[] getMessageList()
          Returns the message list, if any.
 int getReturnCode()
          Returns the return code.
 boolean isExpected()
          Indicates if the exception is expected by the user.
 void unwrap()
          Unwraps the underlying exception and throws it.
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getLocalizedMessage, getMessage, printStackTrace, printStackTrace, printStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ATTRIBUTES_NOT_RETURNED

public static final int ATTRIBUTES_NOT_RETURNED
The return code indicating that resource attributes were not returned.

ATTRIBUTES_NOT_SET

public static final int ATTRIBUTES_NOT_SET
The return code indicating that resource attributes were not set.

MESSAGES_RETURNED

public static final int MESSAGES_RETURNED
The return code indicating that AS/400 messages were returned.

OPERATION_FAILED

public static final int OPERATION_FAILED
The return code indicating that an operation failed.

OPERATION_NOT_SUPPORTED

public static final int OPERATION_NOT_SUPPORTED
The return code indicating that an operation is not supported.

UNKNOWN_ERROR

public static final int UNKNOWN_ERROR
The return code indicating that an unknown problem has occurred.

AUTHORITY_INSUFFICIENT

public static final int AUTHORITY_INSUFFICIENT
The return code indicating that user has insuffient authority.

ATTRIBUTE_READ_ONLY

public static final int ATTRIBUTE_READ_ONLY
The return code indicating that the resource attribute is read-only.
Constructor Detail

ResourceException

public ResourceException()
Constructs a ResourceException object.

ResourceException

public ResourceException(int returnCode)
Constructs a ResourceException object.
Parameters:
returnCode - The return code.

ResourceException

public ResourceException(java.lang.Throwable exception)
Constructs a ResourceException object.
Parameters:
exception - The underlying exception.

ResourceException

public ResourceException(AS400Message[] messageList)
Constructs a ResourceException object.
Parameters:
messageList - The message list.

ResourceException

public ResourceException(int returnCode,
                         java.lang.Throwable exception)
Constructs a ResourceException object.
Parameters:
returnCode - The return code.
exception - The underlying exception.

ResourceException

public ResourceException(int returnCode,
                         java.lang.Throwable exception,
                         boolean expected)
Constructs a ResourceException object.
Parameters:
returnCode - The return code.
exception - The underlying exception.
expected - true if the exception is expected by the user, false otherwise.
Method Detail

getException

public java.lang.Throwable getException()
Returns the underlying exception, if any.
Returns:
The underlying exception, or null if there is none.

getMessageList

public AS400Message[] getMessageList()
Returns the message list, if any.
Returns:
The message list, or null if there is none.

getReturnCode

public int getReturnCode()
Returns the return code.
Specified by:
getReturnCode in interface ReturnCodeException
Returns:
The return code.

isExpected

public boolean isExpected()
Indicates if the exception is expected by the user. For example, if the user explicitly canceled an operation, then the user expects the resulting exception.

unwrap

public void unwrap()
            throws AS400SecurityException,
                   ErrorCompletingRequestException,
                   java.lang.InterruptedException,
                   java.io.IOException,
                   ObjectDoesNotExistException
Unwraps the underlying exception and throws it.
Throws:
AS400SecurityException - If a security or authority error occurs.
ErrorCompletingRequestException - If an error occurs before the request is completed.
java.lang.InterruptedException - If this thread is interrupted.
java.io.IOException - If an error occurs while communicating with the AS/400.
ObjectDoesNotExistException - If the AS/400 object does not exist.