0003-tests-chain-webtest-500-exceptions-to-the-internal-e.patch
tests/utilities.py | ||
---|---|---|
71 | 71 |
) |
72 | 72 |
compat.CompatWcsPublisher.cronjobs = None |
73 | 73 |
pub = compat.CompatWcsPublisher.create_publisher() |
74 |
pub.do_log_internal_error = False |
|
74 | 75 |
# allow saving the user |
75 | 76 |
pub.app_dir = os.path.join(APP_DIR, 'example.net') |
76 | 77 |
pub.site_charset = 'utf-8' |
... | ... | |
222 | 223 |
pass |
223 | 224 | |
224 | 225 | |
226 |
class TestApp(TestApp): |
|
227 |
def do_request(self, *args, **kwargs): |
|
228 |
try: |
|
229 |
return super().do_request(*args, **kwargs) |
|
230 |
except Exception as e: |
|
231 |
pub = get_publisher() |
|
232 |
if pub.last_exc_info: |
|
233 |
raise e from pub.last_exc_info[1] |
|
234 |
raise |
|
235 | ||
236 | ||
225 | 237 |
def get_app(pub, https=False): |
226 | 238 |
extra_environ = {'HTTP_HOST': 'example.net', 'REMOTE_ADDR': '127.0.0.1'} |
227 | 239 |
if https: |
wcs/qommon/publisher.py | ||
---|---|---|
99 | 99 | |
100 | 100 |
app_dir = None |
101 | 101 | |
102 |
last_exc_info = None |
|
103 |
do_log_internal_error = True |
|
104 | ||
102 | 105 |
@property |
103 | 106 |
def form_tokens_dir(self): |
104 | 107 |
return os.path.join(self.app_dir, 'form_tokens') |
... | ... | |
269 | 272 |
original_response = request.response |
270 | 273 |
request.response = HTTPResponse() |
271 | 274 | |
272 |
(exc_type, exc_value, tb) = sys.exc_info() |
|
275 |
self.last_exc_info = (exc_type, exc_value, tb) = sys.exc_info()
|
|
273 | 276 | |
274 | 277 |
if exc_type is NotImplementedError: |
275 | 278 |
get_response().set_header('Content-Type', 'text/html') # set back content-type |
... | ... | |
307 | 310 |
request.response.set_header('Content-Type', 'text/plain') |
308 | 311 |
error_page = plain_error_msg |
309 | 312 | |
310 |
try: |
|
311 |
self.logger.log_internal_error(error_summary, plain_error_msg) |
|
312 |
except socket.error: |
|
313 |
# wilr happen if there is no mail server available and exceptions |
|
314 |
# were configured to be mailed. |
|
315 |
pass |
|
313 |
if self.log_internal_error: |
|
314 |
try: |
|
315 |
self.logger.log_internal_error(error_summary, plain_error_msg) |
|
316 |
except socket.error: |
|
317 |
# will happen if there is no mail server available and exceptions |
|
318 |
# were configured to be mailed. |
|
319 |
pass |
|
316 | 320 | |
317 | 321 |
if exc_type is SystemExit: |
318 | 322 |
raise exc_type |
... | ... | |
724 | 728 |
self.cfg = {} |
725 | 729 | |
726 | 730 |
def process(self, stdin, env): |
731 |
self.last_exc_info = None |
|
727 | 732 |
request = HTTPRequest(stdin, env) |
728 | 733 |
self.response = self.process_request(request) |
729 | 734 |
return self.response |
730 |
- |