use of com.paascloud.base.exception.BusinessException in project paascloud-master by paascloud.
the class Oauth2FeignErrorInterceptor method decode.
/**
* Decode exception.
*
* @param methodKey the method key
* @param response the response
*
* @return the exception
*/
@Override
public Exception decode(final String methodKey, final Response response) {
if (response.status() >= HttpStatus.BAD_REQUEST.value() && response.status() < HttpStatus.INTERNAL_SERVER_ERROR.value()) {
return new HystrixBadRequestException("request exception wrapper");
}
ObjectMapper mapper = new ObjectMapper();
try {
HashMap map = mapper.readValue(response.body().asInputStream(), HashMap.class);
Integer code = (Integer) map.get("code");
String message = (String) map.get("message");
if (code != null) {
ErrorCodeEnum anEnum = ErrorCodeEnum.getEnum(code);
if (anEnum != null) {
if (anEnum == ErrorCodeEnum.GL99990100) {
throw new IllegalArgumentException(message);
} else {
throw new BusinessException(anEnum);
}
} else {
throw new BusinessException(ErrorCodeEnum.GL99990500, message);
}
}
} catch (IOException e) {
log.info("Failed to process response body");
}
return defaultErrorDecoder.decode(methodKey, response);
}
use of com.paascloud.base.exception.BusinessException in project paascloud-master by paascloud.
the class MqMessage method buildMessage.
private static Message buildMessage(String body, String topic, String tag, String key) {
Message message = new Message();
try {
message.setBody(body.getBytes(RemotingHelper.DEFAULT_CHARSET));
} catch (UnsupportedEncodingException e) {
log.error("编码转换,出现异常={}", e.getMessage(), e);
throw new BusinessException(ErrorCodeEnum.TPC100500011);
}
message.setKeys(key);
message.setTopic(topic);
message.setTags(tag);
return message;
}
use of com.paascloud.base.exception.BusinessException in project paascloud-master by paascloud.
the class RenewFilter method run.
/**
* Run object.
*
* @return the object
*/
@Override
public Object run() {
log.info("RenewFilter - token续租...");
RequestContext requestContext = RequestContext.getCurrentContext();
try {
doSomething(requestContext);
} catch (Exception e) {
log.error("RenewFilter - token续租. [FAIL] EXCEPTION={}", e.getMessage(), e);
throw new BusinessException(ErrorCodeEnum.UAC10011041);
}
return null;
}
use of com.paascloud.base.exception.BusinessException in project paascloud-master by paascloud.
the class AuthHeaderFilter method run.
/**
* Run object.
*
* @return the object
*/
@Override
public Object run() {
log.info("AuthHeaderFilter - 开始鉴权...");
RequestContext requestContext = RequestContext.getCurrentContext();
try {
doSomething(requestContext);
} catch (Exception e) {
log.error("AuthHeaderFilter - [FAIL] EXCEPTION={}", e.getMessage(), e);
throw new BusinessException(ErrorCodeEnum.UAC10011041);
}
return null;
}
Aggregations