1
1
/*
2
- * Copyright 2002-2015 the original author or authors.
2
+ * Copyright 2002-2016 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
20
20
* Super class for exceptions that can occur whilst processing expressions.
21
21
*
22
22
* @author Andy Clement
23
+ * @author Phil Webb
23
24
* @since 3.0
24
25
*/
25
26
@ SuppressWarnings ("serial" )
26
27
public class ExpressionException extends RuntimeException {
27
28
28
29
protected String expressionString ;
29
30
30
- protected int position ; // -1 if not known - but should be known in all reasonable cases
31
+ protected int position ; // -1 if not known; should be known in all reasonable cases
31
32
32
33
33
34
/**
34
35
* Construct a new expression exception.
35
- * @param expressionString the expression string
36
36
* @param message a descriptive message
37
37
*/
38
- public ExpressionException (String expressionString , String message ) {
38
+ public ExpressionException (String message ) {
39
39
super (message );
40
- this .position = -1 ;
41
- this .expressionString = expressionString ;
42
40
}
43
41
44
42
/**
45
43
* Construct a new expression exception.
46
- * @param expressionString the expression string
47
- * @param position the position in the expression string where the problem occurred
48
44
* @param message a descriptive message
45
+ * @param cause the underlying cause of this exception
49
46
*/
50
- public ExpressionException (String expressionString , int position , String message ) {
51
- super (message );
52
- this .position = position ;
53
- this .expressionString = expressionString ;
47
+ public ExpressionException (String message , Throwable cause ) {
48
+ super (message , cause );
54
49
}
55
50
56
51
/**
57
52
* Construct a new expression exception.
58
- * @param position the position in the expression string where the problem occurred
53
+ * @param expressionString the expression string
59
54
* @param message a descriptive message
60
55
*/
61
- public ExpressionException (int position , String message ) {
56
+ public ExpressionException (String expressionString , String message ) {
62
57
super (message );
63
- this .position = position ;
58
+ this .expressionString = expressionString ;
59
+ this .position = -1 ;
64
60
}
65
61
66
62
/**
67
63
* Construct a new expression exception.
64
+ * @param expressionString the expression string
68
65
* @param position the position in the expression string where the problem occurred
69
66
* @param message a descriptive message
70
- * @param cause the underlying cause of this exception
71
67
*/
72
- public ExpressionException (int position , String message , Throwable cause ) {
73
- super (message ,cause );
68
+ public ExpressionException (String expressionString , int position , String message ) {
69
+ super (message );
70
+ this .expressionString = expressionString ;
74
71
this .position = position ;
75
72
}
76
73
77
74
/**
78
75
* Construct a new expression exception.
76
+ * @param position the position in the expression string where the problem occurred
79
77
* @param message a descriptive message
80
78
*/
81
- public ExpressionException (String message ) {
79
+ public ExpressionException (int position , String message ) {
82
80
super (message );
81
+ this .position = position ;
83
82
}
84
83
85
84
/**
86
85
* Construct a new expression exception.
86
+ * @param position the position in the expression string where the problem occurred
87
87
* @param message a descriptive message
88
88
* @param cause the underlying cause of this exception
89
89
*/
90
- public ExpressionException (String message , Throwable cause ) {
90
+ public ExpressionException (int position , String message , Throwable cause ) {
91
91
super (message ,cause );
92
+ this .position = position ;
92
93
}
93
94
94
95
@@ -107,8 +108,9 @@ public final int getPosition() {
107
108
}
108
109
109
110
/**
110
- * Return the exception message. Since Spring 4.0 this method returns the
111
- * same result as {@link #toDetailedString()}.
111
+ * Return the exception message.
112
+ * As of Spring 4.0, this method returns the same result as {@link #toDetailedString()}.
113
+ * @see #getSimpleMessage()
112
114
* @see java.lang.Throwable#getMessage()
113
115
*/
114
116
@ Override
@@ -123,11 +125,11 @@ public String getMessage() {
123
125
public String toDetailedString () {
124
126
if (this .expressionString != null ) {
125
127
StringBuilder output = new StringBuilder ();
126
- output .append ("Expression ' " );
128
+ output .append ("Expression [ " );
127
129
output .append (this .expressionString );
128
- output .append ("' " );
129
- if (this .position != - 1 ) {
130
- output .append (" @ " );
130
+ output .append ("] " );
131
+ if (this .position >= 0 ) {
132
+ output .append (" @" );
131
133
output .append (this .position );
132
134
}
133
135
output .append (": " );
@@ -142,6 +144,7 @@ public String toDetailedString() {
142
144
/**
143
145
* Return the exception simple message without including the expression
144
146
* that caused the failure.
147
+ * @since 4.0
145
148
*/
146
149
public String getSimpleMessage () {
147
150
return super .getMessage ();
0 commit comments