com.kingsoft.services.exception.KWSServiceException Maven / Gradle / Ivy
package com.kingsoft.services.exception;
/**
* 继承自 KWSClientException,我们会根据服务器端返回的protobuf消息中的错误码来生成对应的KWSServiceExceptions。
* 如果是服务器不可达或者无响应,将返回KWSClientException。
*/
public class KWSServiceException extends KWSClientException {
private static final long serialVersionUID = 7540177942656913490L;
/**
* The KWS pb 协议code
*/
private String errorCode;
private String errorMsg;
private int httpCode;
private String serviceName;
public KWSServiceException(long requestId, String errorMessage) {
super(requestId, errorMessage);
}
public KWSServiceException(long requestId, String errorMessage,
Exception cause) {
super(requestId, errorMessage, cause);
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
public String getServiceName() {
return serviceName;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
public String getErrorCode() {
return errorCode;
}
public void setHttpCode(int httpcode) {
this.httpCode = httpcode;
}
public int getHttpCode() {
return httpCode;
}
public String getErrorMsg() {
return this.errorMsg;
}
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
@Override
public String getMessage() {
StringBuilder sb = new StringBuilder();
sb.append("{");
sb.append("RequestID: " + getRequestId() + ",");
sb.append("ErrorType: " + this.getClass().getSimpleName() + ",");
sb.append("ErrorCode: " + this.getErrorCode() + ",");
sb.append("ErrorMsg: "
+ (this.getErrorMsg() == null ? "null" : this.getErrorMsg()) + ",");
sb.append("HttpCode: " + getHttpCode() + ",");
sb.append("ServiceName:"
+ (this.getServiceName() == null ? "null" : this.getServiceName() + ","));
sb.append("}");
return sb.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy