Skip to content

Commit 422b5f6

Browse files
committed
Merge PR #826 into 18.0
Signed-off-by guewen
2 parents 12da9db + 9dc1766 commit 422b5f6

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

queue_job/controllers/main.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,9 @@ def _get_failure_values(self, job, traceback_txt, orig_exception):
158158
exception_name = orig_exception.__class__.__name__
159159
if hasattr(orig_exception, "__module__"):
160160
exception_name = orig_exception.__module__ + "." + exception_name
161-
exc_message = getattr(orig_exception, "name", str(orig_exception))
161+
exc_message = (
162+
orig_exception.args[0] if orig_exception.args else str(orig_exception)
163+
)
162164
return {
163165
"exc_info": traceback_txt,
164166
"exc_name": exception_name,

queue_job/tests/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from . import test_run_rob_controller
12
from . import test_runner_channels
23
from . import test_runner_runner
34
from . import test_delayable
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).
2+
3+
from odoo.tests.common import TransactionCase
4+
5+
from ..controllers.main import RunJobController
6+
from ..job import Job
7+
8+
9+
class TestRunJobController(TransactionCase):
10+
def test_get_failure_values(self):
11+
method = self.env["res.users"].mapped
12+
job = Job(method)
13+
ctrl = RunJobController()
14+
rslt = ctrl._get_failure_values(job, "info", Exception("zero", "one"))
15+
self.assertEqual(
16+
rslt, {"exc_info": "info", "exc_name": "Exception", "exc_message": "zero"}
17+
)

0 commit comments

Comments
 (0)