[18.0] [FIX] queue_job: fix exception msg handling#826
Conversation
|
Hi @guewen, |
| 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) |
There was a problem hiding this comment.
So I just noticed above
except (FailedJobError, Exception) as orig_exception:and both of those classes extend Exception, which extends BaseException, which is defined
class BaseException:
args: tuple[Any, ...]so I withdraw my comment about the args[0] guard. As penance, here is a unit test:
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl.html)
from odoo.tests 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"
})|
The modified file doesn't seem covered at all, we won't write its coverage in this PR. I suggest to merge as it. ping @guewen |
Yes, that's why I offered unit test in prior comment. |
'name' attributes for odoo's exception has been deprecated and produces a warning message. This commit fixes the behavior
77e4da3 to
9dc1766
Compare
Missed it, sorry. I've added it in the three PR's. |
|
/ocabot merge patch |
|
On my way to merge this fine PR! |
|
Congratulations, your PR was merged at e416ded. Thanks a lot for contributing to OCA. ❤️ |
Forward port of #824 (16.0)
17.0 PR : #825
'name' attributes for odoo's exception has been deprecated and produces a warning message. This commit fixes the behavior