BadRequest 获取BadRequest 的code 编码以及 content 信息

    /**
     * 获取 gitlab 失败请求的code 码
     * @param e
     * @return
     */
    public static Integer getFeignExceptionBadRequestCode(Exception e){
        int code  = 0;
        try {
            code = ((FeignException.BadRequest) e).status();
        } catch (Exception ex) {
            log.error("获取创建目录失败的冲突信息:", ex);
            code = ((FeignException.Conflict) e).status();
        }
        return code;
    }

    /**
     * 获取 gitlab 失败请求的content 信息
     * @param e
     * @return
     */
    public static String getFeignExceptionBadRequestContent(Exception e){
        String content ;
        try {
            content = new String(((FeignException.BadRequest) e).content());
        } catch (Exception ex) {
            log.error("获取创建目录失败的冲突信息:", ex);
            content = new String(((FeignException.Conflict) e).content());
        }
        return content;
    }

mikuriya,偶遇良缘。

原文地址:https://www.cnblogs.com/mikuriya/p/14265639.html