ReportMakeException.java
1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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());
}
}