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.
|
public ServiceException()
public ServiceException(String errorMessage)
errorMessage
- Error message.public ServiceException(Throwable cause)
Throwable
instance.cause
- A Throwable
instance.public ServiceException(String errorMessage, Throwable cause)
Throwable
instance and error message.errorMessage
- Error message.cause
- A Throwable
instance.public ServiceException(String errorMessage, String errorCode, String requestId, String hostId)
errorMessage
- Error message.errorCode
- Error code.requestId
- Request Id.hostId
- Host Id.public ServiceException(String errorMessage, String errorCode, String requestId, String hostId, Throwable cause)
errorMessage
- Error message.errorCode
- Error code.requestId
- Request Id.hostId
- Host Id.cause
- A Throwable
instance indicates a specific exception.public ServiceException(String errorMessage, String errorCode, String requestId, String hostId, String rawResponseError, Throwable cause)
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.public String getErrorMessage()
public String getErrorCode()
public String getRequestId()
public String getHostId()
public String getRawResponseError()
public void setRawResponseError(String rawResponseError)
rawResponseError
- The error response from OSS.public String getMessage()
getMessage
在类中 Throwable
Copyright © 2019. All Rights Reserved.