Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion queue_job/controllers/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ def _get_failure_values(self, job, traceback_txt, orig_exception):
exception_name = orig_exception.__class__.__name__
if hasattr(orig_exception, "__module__"):
exception_name = orig_exception.__module__ + "." + exception_name
exc_message = getattr(orig_exception, "name", str(orig_exception))
exc_message = (
orig_exception.args[0] if orig_exception.args else str(orig_exception)
)
return {
"exc_info": traceback_txt,
"exc_name": exception_name,
Expand Down
1 change: 1 addition & 0 deletions queue_job/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from . import test_run_rob_controller
from . import test_runner_channels
from . import test_runner_runner
from . import test_delayable
Expand Down
17 changes: 17 additions & 0 deletions queue_job/tests/test_run_rob_controller.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.tests.common import TransactionCase

from ..controllers.main import RunJobController
from ..job import Job


class TestRunJobController(TransactionCase):
def test_get_failure_values(self):
method = self.env["res.users"].mapped
job = Job(method)
ctrl = RunJobController()
rslt = ctrl._get_failure_values(job, "info", Exception("zero", "one"))
self.assertEqual(
rslt, {"exc_info": "info", "exc_name": "Exception", "exc_message": "zero"}
)