com.netease.cloud
public class ServiceException extends ClientException
ServiceException provides callers several pieces of information that can be used to obtain more information about the error and why it occurred. In particular, the errorType field can be used to determine if the caller's request was invalid, or the service encountered an error on the server side while processing it.
Modifier and Type | Class and Description |
---|---|
static class |
ServiceException.ErrorType
Indicates who is responsible (if known) for a failed request.
|
Constructor and Description |
---|
ServiceException(String message)
Constructs a new ServiceException with the specified message.
|
ServiceException(String message,
Exception cause)
Constructs a new ServiceException with the specified message and
exception indicating the root cause.
|
Modifier and Type | Method and Description |
---|---|
String |
getErrorCode()
Returns the error code represented by this exception.
|
ServiceException.ErrorType |
getErrorType()
Indicates who is responsible for this exception (caller, service, or
unknown).
|
String |
getRequestId()
Returns the request ID that uniquely identifies the service request the
caller made.
|
String |
getResource() |
String |
getServiceName()
Returns the name of the service that sent this error response.
|
int |
getStatusCode()
Returns the HTTP status code that was returned with this service
exception.
|
void |
setErrorCode(String errorCode)
Sets the error code represented by this exception.
|
void |
setErrorType(ServiceException.ErrorType errorType)
Sets the type of error represented by this exception (sender, receiver,
or unknown), indicating if this exception was the caller's fault, or the
service's fault.
|
void |
setRequestId(String requestId)
Sets the requestId for this exception.
|
void |
setResource(String resource) |
void |
setServiceName(String serviceName)
Sets the name of the service that sent this error response.
|
void |
setStatusCode(int statusCode)
Sets the HTTP status code that was returned with this service exception.
|
String |
toString()
Returns a string summary of the details of this exception including the
HTTP status code, request ID, error code and error message.
|
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
public ServiceException(String message)
message
- An error message describing what went wrong.public ServiceException(String message, Exception cause)
message
- An error message describing what went wrong.cause
- The root exception that caused this exception to be thrown.public void setRequestId(String requestId)
requestId
- The unique identifier for the service request the caller made.public String getRequestId()
public void setServiceName(String serviceName)
serviceName
- The name of the service that sent this error response.public String getServiceName()
public void setErrorCode(String errorCode)
errorCode
- The error code represented by this exception.public String getErrorCode()
public void setErrorType(ServiceException.ErrorType errorType)
errorType
- The type of error represented by this exception (sender or
receiver), indicating if this exception was the caller's fault
or the service's fault.public ServiceException.ErrorType getErrorType()
public void setStatusCode(int statusCode)
statusCode
- The HTTP status code that was returned with this service
exception.public int getStatusCode()
public String getResource()
public void setResource(String resource)
public String toString()
toString
in class Throwable
Throwable.toString()
Copyright © 2017. All Rights Reserved.