com.aliyun.sdk.gateway.eiam.dev.exception.PopServerException Maven / Gradle / Ivy
The newest version!
package com.aliyun.sdk.gateway.eiam.dev.exception;
import com.aliyun.core.utils.StringUtils;
import darabonba.core.exception.ServerException;
import darabonba.core.utils.CommonUtil;
import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
public class PopServerException extends ServerException {
private String code;
private String message;
private String requestId;
private Map data;
public PopServerException() {
super();
}
public PopServerException(final String message) {
super(message);
}
public PopServerException(final Throwable cause) {
super(cause);
}
public PopServerException(final String message, final Throwable cause) {
super(message, cause);
}
public PopServerException(final String message, final Throwable cause, final boolean enableSuppression,
final boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
public PopServerException(Map map) {
setData(map);
}
public PopServerException(Map map, String message, Throwable cause) {
super(message, cause);
setData(map);
}
@Override
public String getMessage() {
if (!StringUtils.isEmpty(message)) {
return "\n(Code: " + getErrCode() +
"\nMessage: " + getErrMessage() +
"\nRequest ID: " + getRequestId() + ")";
}
return super.getMessage();
}
public String getErrMessage() {
return message;
}
public void setErrMessage(String message) {
this.message = message;
}
public String getErrCode() {
return code;
}
public void setErrCode(String code) {
this.code = code;
}
public String getRequestId() {
return requestId;
}
public void setRequestId(String requestId) {
this.requestId = requestId;
}
public void setData(Map map) {
this.setErrCode(String.valueOf(map.get("code")));
this.setErrMessage(String.valueOf(map.get("message")));
Object obj = map.get("data");
if (obj == null) {
return;
}
if (obj instanceof Map) {
data = (Map) obj;
if (!CommonUtil.isUnset(data.get("RequestId"))) {
this.setRequestId(data.get("RequestId").toString());
} else if (!CommonUtil.isUnset(data.get("requestId"))) {
this.setRequestId(data.get("requestId").toString());
}
return;
}
Map hashMap = new HashMap();
Field[] declaredFields = obj.getClass().getDeclaredFields();
for (Field field : declaredFields) {
field.setAccessible(true);
try {
hashMap.put(field.getName(), field.get(obj));
} catch (Exception e) {
continue;
}
}
this.data = hashMap;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy