ReportMakeException.java 1.5 KB
package com.lhcredit.common.exception;

import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Arrays;
import java.util.stream.Collectors;

public class ReportMakeException extends  RuntimeException{

    public static  Logger reportMakeLog = LoggerFactory.getLogger("report_make_log");

    private static final long serialVersionUID = 1L;
    private String message;
    private String code;
    private Class tclass;

    public ReportMakeException(String message, Class tclass)
    {
        this.message = message;
        this.tclass=tclass;
    }
    public ReportMakeException(Class tclass,String... message)
    {
        this.message = Arrays.stream(message).collect(Collectors.joining(" "));
        reportMakeLog.error(this.message);
        reportMakeLog.error(tclass.getName()+"  "+this.message);
    }
    public static void makeReportError(Object object,Exception e){
        String jsonString = JSON.toJSONString(object, SerializerFeature.PrettyFormat);
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        e.printStackTrace(pw);
        reportMakeLog.error("报告生成失败:==================================================");
        reportMakeLog.error(jsonString);
        reportMakeLog.error(sw.toString());
    }


}