File tree Expand file tree Collapse file tree 2 files changed +28
-11
lines changed Expand file tree Collapse file tree 2 files changed +28
-11
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
10
10
## Changed
11
11
12
12
- In ` TaskWithState.process_get_state() ` any changes to ` process_data ` are now ignored. https://github.com/OpenDataServices/lib-cove-web-2/issues/14
13
+ - Provide a specific error when JSON parsing fails, rather than generic "There was an error."
13
14
14
15
## [ 0.3.0] - 2023-09-14
15
16
Original file line number Diff line number Diff line change @@ -149,17 +149,33 @@ def view_does_not_exist(self, request):
149
149
150
150
def view_data_has_error (self , request , supplied_data ):
151
151
"""Called if the supplied data has any error set."""
152
- return render (
153
- request ,
154
- self .error_template ,
155
- {
156
- "sub_title" : _ ("Sorry, there was an error." ),
157
- "link" : "index" ,
158
- "link_text" : _ ("Go to Home page" ),
159
- "msg" : _ ("There was an error." ),
160
- },
161
- status = 500 ,
162
- )
152
+ if supplied_data .error .startswith ("JSON: Data parsing error" ):
153
+ return render (
154
+ request ,
155
+ self .error_template ,
156
+ {
157
+ "sub_title" : _ ("Data parsing error." ),
158
+ "link" : "index" ,
159
+ "link_text" : _ ("Go to Home page" ),
160
+ "msg" : _ (
161
+ "The data is not valid JSON. "
162
+ + "Use a JSON validator tool to correct your data."
163
+ ),
164
+ },
165
+ status = 500 ,
166
+ )
167
+ else :
168
+ return render (
169
+ request ,
170
+ self .error_template ,
171
+ {
172
+ "sub_title" : _ ("Sorry, there was an error." ),
173
+ "link" : "index" ,
174
+ "link_text" : _ ("Go to Home page" ),
175
+ "msg" : _ ("There was an error." ),
176
+ },
177
+ status = 500 ,
178
+ )
163
179
164
180
def view_has_expired (self , request , supplied_data ):
165
181
"""Called if the data has expired and has now been deleted.
You can’t perform that action at this time.
0 commit comments