5
5
6
6
package com .fasterxml .jackson .core ;
7
7
8
+ import com .fasterxml .jackson .core .exc .JsonReadException ;
8
9
import com .fasterxml .jackson .core .util .RequestPayload ;
9
10
10
11
/**
11
12
* Exception type for parsing problems, used when non-well-formed content
12
13
* (content that does not conform to JSON syntax as per specification)
13
14
* is encountered.
14
15
*/
15
- public class JsonParseException extends JsonProcessingException {
16
+ public class JsonParseException extends JsonReadException
17
+ {
16
18
private static final long serialVersionUID = 2L ; // 2.7
17
19
18
- // transient since 2.7.4
19
- protected transient JsonParser _processor ;
20
-
21
- /**
22
- * Optional payload that can be assigned to pass along for error reporting
23
- * or handling purposes. Core streaming parser implementations DO NOT
24
- * initialize this; it is up to using applications and frameworks to
25
- * populate it.
26
- *
27
- * @since 2.8
28
- */
29
- protected RequestPayload _requestPayload ;
30
-
31
20
@ Deprecated // since 2.7
32
21
public JsonParseException (String msg , JsonLocation loc ) {
33
- super (msg , loc );
22
+ super (msg , loc , null );
34
23
}
35
24
36
25
@ Deprecated // since 2.7
@@ -46,32 +35,28 @@ public JsonParseException(String msg, JsonLocation loc, Throwable root) {
46
35
* @since 2.7
47
36
*/
48
37
public JsonParseException (JsonParser p , String msg ) {
49
- super (msg , (p == null ) ? null : p .getCurrentLocation ());
50
- _processor = p ;
38
+ super (p , msg );
51
39
}
52
40
53
41
/**
54
42
* @since 2.7
55
43
*/
56
44
public JsonParseException (JsonParser p , String msg , Throwable root ) {
57
- super (msg , (p == null ) ? null : p .getCurrentLocation (), root );
58
- _processor = p ;
45
+ super (p , msg , root );
59
46
}
60
47
61
48
/**
62
49
* @since 2.7
63
50
*/
64
51
public JsonParseException (JsonParser p , String msg , JsonLocation loc ) {
65
- super (msg , loc );
66
- _processor = p ;
52
+ super (p , msg , loc );
67
53
}
68
54
69
55
/**
70
56
* @since 2.7
71
57
*/
72
58
public JsonParseException (JsonParser p , String msg , JsonLocation loc , Throwable root ) {
73
59
super (msg , loc , root );
74
- _processor = p ;
75
60
}
76
61
77
62
/**
@@ -82,6 +67,7 @@ public JsonParseException(JsonParser p, String msg, JsonLocation loc, Throwable
82
67
*
83
68
* @since 2.7
84
69
*/
70
+ @ Override
85
71
public JsonParseException withParser (JsonParser p ) {
86
72
_processor = p ;
87
73
return this ;
@@ -95,49 +81,33 @@ public JsonParseException withParser(JsonParser p) {
95
81
*
96
82
* @since 2.8
97
83
*/
84
+ @ Override
98
85
public JsonParseException withRequestPayload (RequestPayload p ) {
99
86
_requestPayload = p ;
100
87
return this ;
101
88
}
102
-
89
+
90
+ // NOTE: overloaded in 2.10 just to retain binary compatibility with 2.9 (remove from 3.0)
103
91
@ Override
104
92
public JsonParser getProcessor () {
105
- return _processor ;
93
+ return super . getProcessor () ;
106
94
}
107
95
108
- /**
109
- * Method that may be called to find payload that was being parsed, if
110
- * one was specified for parser that threw this Exception.
111
- *
112
- * @return request body, if payload was specified; `null` otherwise
113
- *
114
- * @since 2.8
115
- */
96
+ // NOTE: overloaded in 2.10 just to retain binary compatibility with 2.9 (remove from 3.0)
97
+ @ Override
116
98
public RequestPayload getRequestPayload () {
117
- return _requestPayload ;
99
+ return super . getRequestPayload () ;
118
100
}
119
101
120
- /**
121
- * The method returns the String representation of the request payload if
122
- * one was specified for parser that threw this Exception.
123
- *
124
- * @return request body as String, if payload was specified; `null` otherwise
125
- *
126
- * @since 2.8
127
- */
102
+ // NOTE: overloaded in 2.10 just to retain binary compatibility with 2.9 (remove from 3.0)
103
+ @ Override
128
104
public String getRequestPayloadAsString () {
129
- return ( _requestPayload != null ) ? _requestPayload . toString () : null ;
105
+ return super . getRequestPayloadAsString () ;
130
106
}
131
107
132
- /**
133
- * Overriding the getMessage() to include the request body
134
- */
108
+ // NOTE: overloaded in 2.10 just to retain binary compatibility with 2.9 (remove from 3.0)
135
109
@ Override
136
110
public String getMessage () {
137
- String msg = super .getMessage ();
138
- if (_requestPayload != null ) {
139
- msg += "\n Request payload : " + _requestPayload .toString ();
140
- }
141
- return msg ;
111
+ return super .getMessage ();
142
112
}
143
113
}
0 commit comments