|
@@ -166,7 +166,22 @@ class FlaskContext(BaseContext):
|
166
|
166
|
exception_class: typing.Type[Exception],
|
167
|
167
|
http_code: int,
|
168
|
168
|
) -> None:
|
169
|
|
- raise NotImplementedError('TODO')
|
|
169
|
+ def return_response_error(exc):
|
|
170
|
+ error_builder = self.get_default_error_builder()
|
|
171
|
+ error_body = error_builder.build_from_exception(
|
|
172
|
+ exc,
|
|
173
|
+ include_traceback=self.is_debug(),
|
|
174
|
+ )
|
|
175
|
+ dumped = error_builder.dump(error_body).data
|
|
176
|
+ return self.get_response(
|
|
177
|
+ json.dumps(dumped),
|
|
178
|
+ http_code,
|
|
179
|
+ )
|
|
180
|
+
|
|
181
|
+ self.app.register_error_handler(
|
|
182
|
+ exception_class,
|
|
183
|
+ return_response_error,
|
|
184
|
+ )
|
170
|
185
|
|
171
|
186
|
def is_debug(self) -> bool:
|
172
|
187
|
return self.debug
|