1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package tools.gsf.runtime;
18
19 import COM.FutureTense.Util.ftErrors;
20
21
22
23
24
25
26
27
28 public class CSRuntimeException extends RuntimeException {
29 private static final long serialVersionUID = 4188899178173205443L;
30 private final int errno;
31 private final ftErrors complexError;
32
33
34
35
36
37 public CSRuntimeException(final String msg, final int errno) {
38 super(msg + " (errno=" + errno + ")");
39 this.errno = errno;
40 this.complexError = null;
41 }
42
43
44
45
46
47
48 public CSRuntimeException(final String msg, final int errno, final Throwable cause) {
49 super(msg + " (errno=" + errno + ")", cause);
50 this.errno = errno;
51 this.complexError = null;
52 }
53
54
55
56
57
58
59 public CSRuntimeException(final String msg, final ftErrors complexError, final int errno) {
60 super(msg, complexError.getCause());
61 this.errno = errno;
62 this.complexError = complexError;
63 }
64
65
66
67
68 public final int getErrno() {
69 return errno;
70 }
71
72
73
74
75 public final ftErrors getComplexError() {
76 return complexError;
77 }
78
79
80
81
82
83
84 @Override
85 public String getMessage() {
86
87 final StringBuilder builder = new StringBuilder();
88 builder.append(super.getMessage());
89 if (complexError != null) {
90 if (errno != complexError.getReason()) {
91 builder.append("|errno:").append(errno);
92 }
93 builder.append("|reason:").append(complexError.getReason());
94 builder.append("|message:");
95 builder.append(complexError.getMessage());
96
97 final int details = complexError.details();
98 if (details > 0) {
99 builder.append("|details:");
100 }
101 for (int i = 0; i < details; i++) {
102 builder.append(" ");
103 builder.append(complexError.detail(i));
104 }
105 } else {
106 builder.append("|errno:").append(errno);
107 }
108 return builder.toString();
109
110 }
111 }