All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kingsoft.services.exception.KWSClientException Maven / Gradle / Ivy

package com.kingsoft.services.exception;

/**
 * KWS Exception基类,调用服务过程中抛出的任何exception都将继承此类
 * 
 * 其有一个子类KWSServiceExceptions,
 * 我们会根据服务器端返回的protobuf消息中的错误码来生成对应的KWSServiceExceptions。
 * 如果是服务器不可达或者无响应,将返回KWSClientException。
 * 
 * @see KWSServiceException
 */
public class KWSClientException extends RuntimeException {
  private static final long serialVersionUID = 6159687730630709959L;
  private long requestId;

  public KWSClientException(long requestId, String message, Throwable t) {
    super(String.format("requestId:%d, message:%s, inner Exception:%s",
        requestId,
        message,
        t == null ? "" : t.getMessage())
        , t);
    this.requestId = requestId;
   
  }

  public KWSClientException(long requestId, String message) {
    super(message);
    this.requestId = requestId;
  }
  
  
  public KWSClientException(String message, Throwable t) {
    this(0, message, t);
  }

  public KWSClientException(String message) {
    this(0, message);
  }
  
  public long getRequestId() {
    return requestId;
  }

  public void setRequestId(long requestId) {
    this.requestId = requestId;
  }

  public boolean isRetryable() {
    return true;
  }

  @Override
  public String getMessage() {
    String msg = String.format("requestId:%s, message:%s", this.getRequestId(),
        super.getMessage());
    return msg;
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy