com.aliyun.openservices
类 ServiceException

java.lang.Object
  继承者 java.lang.Throwable
      继承者 java.lang.Exception
          继承者 java.lang.RuntimeException
              继承者 com.aliyun.openservices.ServiceException
所有已实现的接口:
Serializable
直接已知子类:
OSSException, OTSException

public class ServiceException
extends RuntimeException

表示阿里云服务返回的错误消息。

ServiceException用于处理阿里云服务返回的错误消息。比如,用于身份验证的Access ID不存在, 则会抛出ServiceException(严格上讲,会是该类的一个继承类。比如,OTSClient会抛出OTSException)。 异常中包含了错误代码,用于让调用者进行特定的处理。

ClientException表示的则是在向阿里云服务发送请求时出现的错误,以及客户端无法处理返回结果。 例如,在发送请求时网络连接不可用,则会抛出ClientException的异常。

通常来讲,调用者只需要处理ServiceException。因为该异常表明请求被服务处理,但处理的结果表明 存在错误。异常中包含了细节的信息,特别是错误代码,可以帮助调用者进行处理。

另请参见:
序列化表格

构造方法摘要
ServiceException()
          构造新实例。
ServiceException(String message)
          用给定的异常信息构造新实例。
ServiceException(String message, Throwable cause)
          用异常消息和表示异常原因的对象构造新实例。
ServiceException(String message, Throwable cause, String errorCode, String requestId, String hostId)
          用异常消息和表示异常原因及其他信息的对象构造新实例。
ServiceException(Throwable cause)
          用表示异常原因的对象构造新实例。
 
方法摘要
 String getErrorCode()
          返回错误代码的字符串表示。
 String getHostId()
          返回Host标识。
 String getRequestId()
          返回Request标识。
 String toString()
           
 
从类 java.lang.Throwable 继承的方法
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

构造方法详细信息

ServiceException

public ServiceException()
构造新实例。


ServiceException

public ServiceException(String message)
用给定的异常信息构造新实例。

参数:
message - 异常信息。

ServiceException

public ServiceException(Throwable cause)
用表示异常原因的对象构造新实例。

参数:
cause - 异常原因。

ServiceException

public ServiceException(String message,
                        Throwable cause)
用异常消息和表示异常原因的对象构造新实例。

参数:
message - 异常信息。
cause - 异常原因。

ServiceException

public ServiceException(String message,
                        Throwable cause,
                        String errorCode,
                        String requestId,
                        String hostId)
用异常消息和表示异常原因及其他信息的对象构造新实例。

参数:
message - 异常信息。
cause - 异常原因。
errorCode - 错误代码。
requestId - Request ID。
hostId - Host ID。
方法详细信息

getErrorCode

public String getErrorCode()
返回错误代码的字符串表示。

返回:
错误代码的字符串表示。

getRequestId

public String getRequestId()
返回Request标识。

返回:
Request标识。

getHostId

public String getHostId()
返回Host标识。

返回:
Host标识。

toString

public String toString()
覆盖:
Throwable 中的 toString


Copyright © 2013. All Rights Reserved.