Skip to content
Snippets Groups Projects
Commit 3681a72c authored by vlorentz's avatar vlorentz
Browse files

Add the whole traceback in error messages.

No change in swh-web will only show the first line;
but this will include the detailed error in notification emails.
parent 523f9158
No related branches found
No related tags found
1 merge request!125Add the whole traceback in error messages.
......@@ -6,6 +6,7 @@
import abc
import io
import logging
import traceback
from typing import ClassVar, Set
from psycopg2.extensions import QueryCanceledError
......@@ -141,10 +142,12 @@ class BaseVaultCooker(metaclass=abc.ABCMeta):
self.backend.set_progress(self.BUNDLE_TYPE, self.swhid, str(e))
except Exception:
self.backend.set_status(self.BUNDLE_TYPE, self.swhid, "failed")
tb = traceback.format_exc()
self.backend.set_progress(
self.BUNDLE_TYPE,
self.swhid,
"Internal Server Error. This incident will be reported.",
f"Internal Server Error. This incident will be reported.\n"
f"The full error was:\n\n{tb}",
)
logging.exception("Bundle cooking failed.")
else:
......
# Copyright (C) 2018 The Software Heritage developers
# Copyright (C) 2018-2021 The Software Heritage developers
# See the AUTHORS file at the top-level directory of this distribution
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
import textwrap
from unittest.mock import MagicMock
from swh.model.identifiers import CoreSWHID
......@@ -56,7 +57,16 @@ def test_code_exception_cook():
cooker.backend.put_bundle.assert_not_called()
cooker.backend.set_status.assert_called_with(TEST_BUNDLE_TYPE, TEST_SWHID, "failed")
assert "Nope" not in cooker.backend.set_progress.call_args[0][2]
assert cooker.backend.set_progress.call_args[0][2].startswith(
textwrap.dedent(
"""\
Internal Server Error. This incident will be reported.
The full error was:
Traceback (most recent call last):
"""
)
)
cooker.backend.send_notif.assert_called_with(TEST_BUNDLE_TYPE, TEST_SWHID)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment