com.aliyun.oss

## 类 ServiceException

- java.lang.Object
- - java.lang.Throwable
  - - java.lang.Exception
    - - java.lang.RuntimeException
      - - com.aliyun.oss.ServiceException

- 所有已实现的接口:
    Serializable
  直接已知子类:
    OSSException

      public class ServiceException
      extends RuntimeException

  This is the base exception class to represent any expected or unexpected OSS server side errors.

  `ServiceException` is converted from error code from OSS response. For example, when OSS tries to authenticate a request, if Access ID does not exist, the SDK will throw a `ServiceException` or its subclass instance with the specific error code, which the caller could handle that with specific logic.

  On the other side, `ClientException` is the class to represent any exception in OSS client side. Generally ClientException occurs either before sending the request or after receving the response from OSS server side. For example, if the network is broken when it tries to send a request, then the SDK will throw a `ClientException` instance.

  So generally speaking, the caller only needs to handle `ServiceException` properly as it means the request is processed, but not completely finished due to different errors. The error code in the exception is a good diagnostics information. Sometimes these exceptions are completely expected.

  另请参阅:
    序列化表格

- - ### 构造器概要

    构造器
    构造器和说明
    `ServiceException()` Creates a default instance.
    `ServiceException(String errorMessage)` Creates an instance with the error message.
    `ServiceException(String errorMessage, String errorCode, String requestId, String hostId)` Creates an instance with error message, error code, request id, host id.
    `ServiceException(String errorMessage, String errorCode, String requestId, String hostId, String rawResponseError, Throwable cause)` Creates an instance with error message, error code, request id, host id, OSS response error, and a Throwable instance.
    `ServiceException(String errorMessage, String errorCode, String requestId, String hostId, Throwable cause)` Creates an instance with error message, error code, request id, host id.
    `ServiceException(String errorMessage, Throwable cause)` Creates an instance with a `Throwable` instance and error message.
    `ServiceException(Throwable cause)` Creates an instance with a `Throwable` instance.

  - ### 方法概要

    方法
    限定符和类型 | 方法和说明
    --- | ---
    `String` | `getErrorCode()` Gets the error code.
    `String` | `getErrorMessage()` Gets error message.
    `String` | `getHostId()` Gets the host id.
    `String` | `getMessage()`
    `String` | `getRawResponseError()` Gets the error message in OSS response.
    `String` | `getRequestId()` Gets the request id.
    `void` | `setRawResponseError(String rawResponseError)` Sets the error response from OSS.

    - ### 从类继承的方法 java.lang.Throwable

      `addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

    - ### 从类继承的方法 java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### 构造器详细资料

    - #### ServiceException

          public ServiceException()

      Creates a default instance.

    - #### ServiceException

          public ServiceException(String errorMessage)

      Creates an instance with the error message.
      参数:
        `errorMessage` - Error message.

    - #### ServiceException

          public ServiceException(Throwable cause)

      Creates an instance with a `Throwable` instance.
      参数:
        `cause` - A `Throwable` instance.

    - #### ServiceException

          public ServiceException(String errorMessage,
                          Throwable cause)

      Creates an instance with a `Throwable` instance and error message.
      参数:
        `errorMessage` - Error message.
        `cause` - A `Throwable` instance.

    - #### ServiceException

          public ServiceException(String errorMessage,
                          String errorCode,
                          String requestId,
                          String hostId)

      Creates an instance with error message, error code, request id, host id.
      参数:
        `errorMessage` - Error message.
        `errorCode` - Error code.
        `requestId` - Request Id.
        `hostId` - Host Id.

    - #### ServiceException

          public ServiceException(String errorMessage,
                          String errorCode,
                          String requestId,
                          String hostId,
                          Throwable cause)

      Creates an instance with error message, error code, request id, host id.
      参数:
        `errorMessage` - Error message.
        `errorCode` - Error code.
        `requestId` - Request Id.
        `hostId` - Host Id.
        `cause` - A `Throwable` instance indicates a specific exception.

    - #### ServiceException

          public ServiceException(String errorMessage,
                          String errorCode,
                          String requestId,
                          String hostId,
                          String rawResponseError,
                          Throwable cause)

      Creates an instance with error message, error code, request id, host id, OSS response error, and a Throwable instance.
      参数:
        `errorMessage` - Error message.
        `errorCode` - Error code.
        `requestId` - Request Id.
        `hostId` - Host Id.
        `rawResponseError` - OSS error message in response.
        `cause` - A `Throwable` instance indicates a specific exception.

  - ### 方法详细资料

    - #### getErrorMessage

          public String getErrorMessage()

      Gets error message.
      返回:
        Error message.

    - #### getErrorCode

          public String getErrorCode()

      Gets the error code.
      返回:
        The error code in string.

    - #### getRequestId

          public String getRequestId()

      Gets the request id.
      返回:
        The request Id in string.

    - #### getHostId

          public String getHostId()

      Gets the host id.
      返回:
        The host Id in string.

    - #### getRawResponseError

          public String getRawResponseError()

      Gets the error message in OSS response.
      返回:
        Error response in string.

    - #### setRawResponseError

          public void setRawResponseError(String rawResponseError)

      Sets the error response from OSS.
      参数:
        `rawResponseError` - The error response from OSS.

    - #### getMessage

          public String getMessage()

      覆盖:
        `getMessage` 在类中 `Throwable`

Copyright © 2020. All Rights Reserved.