[FIX] base, web: log correctly error in assets
Since [1], when an error exists in an asset, the assets raise a not
found exception. The issue, is that, there is no feedback for the
developer to find the error.
Now, a new console log with the error details is shown.
[1] : bf3b6b0b8b
closes odoo/odoo#141705
Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
This commit is contained in:
@@ -129,6 +129,7 @@ class Binary(http.Controller):
|
||||
elif js and bundle.javascripts:
|
||||
attachment = bundle.js()
|
||||
except ValueError as e:
|
||||
_logger.error(e.args[0])
|
||||
raise request.not_found() from e
|
||||
if not attachment:
|
||||
raise request.not_found()
|
||||
|
||||
@@ -105,7 +105,7 @@ class TestWebAssets(odoo.tests.HttpCase):
|
||||
def test_assets_url_validation(self):
|
||||
website_id = self.env['website'].search([], limit=1, order='id desc').id
|
||||
|
||||
with odoo.tools.mute_logger('odoo.addons.base.models.ir_asset'):
|
||||
with odoo.tools.mute_logger('odoo.addons.web.controllers.binary'):
|
||||
self.assertEqual(
|
||||
self.url_open(f'/web/assets/{website_id}/debug/hello/web.assets_frontend.css', allow_redirects=False).status_code,
|
||||
404,
|
||||
|
||||
@@ -107,21 +107,15 @@ class IrAsset(models.Model):
|
||||
if not debug_assets:
|
||||
bundle_name, min_ = bundle_name.rsplit('.', 1)
|
||||
if min_ != 'min':
|
||||
msg = "'min' expected in extension in non debug mode"
|
||||
_logger.error(msg)
|
||||
raise ValueError(msg)
|
||||
raise ValueError("'min' expected in extension in non debug mode")
|
||||
if asset_type == 'css':
|
||||
if bundle_name.endswith('.rtl'):
|
||||
bundle_name = bundle_name[:-4]
|
||||
rtl = True
|
||||
elif asset_type != 'js':
|
||||
msg = 'Only js and css assets bundle are supported for now'
|
||||
_logger.error(msg)
|
||||
raise ValueError(msg)
|
||||
raise ValueError('Only js and css assets bundle are supported for now')
|
||||
if len(bundle_name.split('.')) != 2:
|
||||
msg = f'{bundle_name} is not a valid bundle name, should have two parts'
|
||||
_logger.error(msg)
|
||||
raise ValueError(msg)
|
||||
raise ValueError(f'{bundle_name} is not a valid bundle name, should have two parts')
|
||||
return bundle_name, rtl, asset_type
|
||||
|
||||
@tools.conditional(
|
||||
|
||||
Reference in New Issue
Block a user