Only log a single message in utils.error.
This helps with seeing the full message with logfail.
This commit is contained in:
parent
9d9372c6a8
commit
a4bc4ad478
@ -49,12 +49,15 @@ def handle_fatal_exc(exc, args, title, *, pre_text='', post_text=''):
|
||||
post_text: The text to be displayed after the exception text.
|
||||
"""
|
||||
if args.no_err_windows:
|
||||
log.misc.exception("Handling fatal {} with --no-err-windows!".format(
|
||||
_get_name(exc)))
|
||||
log.misc.error("title: {}".format(title))
|
||||
log.misc.error("pre_text: {}".format(pre_text))
|
||||
log.misc.error("post_text: {}".format(post_text))
|
||||
log.misc.error("exception text: {}".format(str(exc) or 'none'))
|
||||
lines = [
|
||||
"Handling fatal {} with --no-err-windows!".format(_get_name(exc)),
|
||||
"",
|
||||
"title: {}".format(title),
|
||||
"pre_text: {}".format(pre_text),
|
||||
"post_text: {}".format(post_text),
|
||||
"exception text: {}".format(str(exc) or 'none'),
|
||||
]
|
||||
log.misc.exception('\n'.join(lines))
|
||||
else:
|
||||
if pre_text:
|
||||
msg_text = '{}: {}'.format(pre_text, exc)
|
||||
|
@ -601,16 +601,19 @@ class TestSendOrListen:
|
||||
with pytest.raises(ipc.Error):
|
||||
ipc.send_or_listen(args)
|
||||
|
||||
msgs = [e.message for e in caplog.records()]
|
||||
records = caplog.records()
|
||||
assert len(records) == 1
|
||||
|
||||
error_msgs = [
|
||||
'Handling fatal misc.ipc.{} with --no-err-windows!'.format(
|
||||
exc_name),
|
||||
'',
|
||||
'title: Error while connecting to running instance!',
|
||||
'pre_text: ',
|
||||
'post_text: Maybe another instance is running but frozen?',
|
||||
'exception text: {}'.format(exc_msg),
|
||||
]
|
||||
assert msgs[-5:] == error_msgs
|
||||
assert records[0].msg == '\n'.join(error_msgs)
|
||||
|
||||
@pytest.mark.posix # Flaky on Windows
|
||||
def test_error_while_listening(self, qlocalserver_mock, caplog, args):
|
||||
@ -623,16 +626,19 @@ class TestSendOrListen:
|
||||
with pytest.raises(ipc.Error):
|
||||
ipc.send_or_listen(args)
|
||||
|
||||
msgs = [e.message for e in caplog.records()]
|
||||
records = caplog.records()
|
||||
assert len(records) == 1
|
||||
|
||||
error_msgs = [
|
||||
'Handling fatal misc.ipc.ListenError with --no-err-windows!',
|
||||
'',
|
||||
'title: Error while connecting to running instance!',
|
||||
'pre_text: ',
|
||||
'post_text: Maybe another instance is running but frozen?',
|
||||
'exception text: Error while listening to IPC server: Error '
|
||||
'string (error 4)',
|
||||
]
|
||||
assert msgs[-5:] == error_msgs
|
||||
assert records[0].msg == '\n'.join(error_msgs)
|
||||
|
||||
|
||||
def test_long_username(fake_runtime_dir):
|
||||
|
@ -55,15 +55,19 @@ def test_no_err_windows(caplog, exc, name, exc_text):
|
||||
with caplog.atLevel(logging.ERROR):
|
||||
error.handle_fatal_exc(e, Args(no_err_windows=True), 'title',
|
||||
pre_text='pre', post_text='post')
|
||||
msgs = [rec.message for rec in caplog.records()]
|
||||
|
||||
records = caplog.records()
|
||||
assert len(records) == 1
|
||||
|
||||
expected = [
|
||||
'Handling fatal {} with --no-err-windows!'.format(name),
|
||||
'',
|
||||
'title: title',
|
||||
'pre_text: pre',
|
||||
'post_text: post',
|
||||
'exception text: {}'.format(exc_text),
|
||||
]
|
||||
assert msgs[-5:] == expected
|
||||
assert records[0].msg == '\n'.join(expected)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('pre_text, post_text, expected', [
|
||||
|
Loading…
Reference in New Issue
Block a user