1
2
3
4
5
6 package gov.nist.secauto.metaschema.core.metapath;
7
8
9
10
11
12 public abstract class AbstractCodedMetapathException
13 extends MetapathException {
14
15
16
17
18 private static final long serialVersionUID = 1L;
19
20
21
22
23 private final int code;
24
25
26
27
28
29
30
31
32
33
34 public AbstractCodedMetapathException(int code, String message) {
35 super(message);
36 this.code = code;
37 }
38
39
40
41
42
43
44
45
46
47
48
49
50 public AbstractCodedMetapathException(int code, String message, Throwable cause) {
51 super(message, cause);
52 this.code = code;
53 }
54
55
56
57
58
59
60
61
62
63
64 public AbstractCodedMetapathException(int code, Throwable cause) {
65 super(cause);
66 this.code = code;
67 }
68
69 @Override
70 public String getMessage() {
71 return String.format("%s: %s", getCodeAsString(), super.getMessage());
72 }
73
74
75
76
77
78
79 public int getCode() {
80 return code;
81 }
82
83
84
85
86
87
88 public abstract String getCodePrefix();
89
90
91
92
93
94
95 protected String getCodeAsString() {
96 return String.format("%s%04d", getCodePrefix(), getCode());
97 }
98 }