1
1
package com .relogiclabs .jschema .exception ;
2
2
3
3
import com .relogiclabs .jschema .message .ErrorDetail ;
4
+ import com .relogiclabs .jschema .type .EValue ;
4
5
import lombok .Getter ;
5
6
import lombok .Setter ;
6
7
import org .antlr .v4 .runtime .Token ;
7
8
9
+ import java .lang .reflect .Method ;
10
+
11
+ import static com .relogiclabs .jschema .internal .util .ReflectionHelper .getSignature ;
8
12
import static com .relogiclabs .jschema .message .MessageFormatter .formatForSchema ;
9
13
10
14
@ Getter @ Setter
11
15
public class InvocationRuntimeException extends MultilevelRuntimeException {
12
16
private String subject ;
13
-
14
- public InvocationRuntimeException (String message ) {
15
- super (message );
16
- }
17
+ private Method method ;
17
18
18
19
public InvocationRuntimeException (String code , String message ) {
19
20
super (code , message );
20
21
}
21
22
22
- public InvocationRuntimeException (String code , String message , Throwable cause ) {
23
- super (code , message , cause );
24
- }
25
-
26
23
public InvocationRuntimeException (ErrorDetail detail , Throwable cause ) {
27
24
super (detail , cause );
28
25
}
@@ -31,6 +28,16 @@ public InvocationRuntimeException(ErrorDetail detail, Throwable cause) {
31
28
public RuntimeException translate (Token token ) {
32
29
if (isHighLevel () || subject == null ) return this ;
33
30
return new InvocationRuntimeException (formatForSchema (getCode (),
34
- getMessage () + " '" + subject + "'" , token ), this );
31
+ addNative (getMessage () + " '" + subject + "'" ), token ), this );
32
+ }
33
+
34
+ protected String addNative (String message ) {
35
+ if (method == null ) return message ;
36
+ return message + " with native: " + getSignature (method );
37
+ }
38
+
39
+ protected static String addSelf (String message , EValue self ) {
40
+ if (self == null ) return message ;
41
+ return message + " in " + self .getType ();
35
42
}
36
43
}
0 commit comments