OCA / server-env

Tools to manage environment-dependent configuration
GNU Affero General Public License v3.0
57 stars 157 forks source link

[14.0] [IMP] `server_environment`: don't print stack trace when the field can't be read #116

Closed ivantodorovich closed 1 year ago

ivantodorovich commented 2 years ago

Sample log before:

2022-07-12 14:25:43,330 88 ERROR odoodb_test odoo.addons.server_environment.models.server_env_mixin: error trying to read field FIELD_NAME in section SECTION_NAME
Traceback (most recent call last):
  File "/odoo/src/odoo/api.py", line 793, in get
    return field_cache[record._ids[0]]
KeyError: 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/odoo/src/odoo/fields.py", line 972, in __get__
    value = env.cache.get(record, self)
  File "/odoo/src/odoo/api.py", line 796, in get
    raise CacheMiss(record, field)
odoo.exceptions.CacheMiss: 'storage.backend(1,).served_by'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/odoo/external-src/server-env/server_environment/models/server_env_mixin.py", line 195, in _server_env_read_from_config
    value = getter(section_name, field_name)
  File "/usr/lib/python3.7/configparser.py", line 818, in getint
    fallback=fallback, **kwargs)
  File "/usr/lib/python3.7/configparser.py", line 808, in _get_conv
    **kwargs)
  File "/usr/lib/python3.7/configparser.py", line 802, in _get
    return conv(self.get(section, option, **kwargs))
ValueError: invalid literal for int() with base 10: ''

After:

2022-07-12 14:25:43,330 88 ERROR odoodb_test odoo.addons.server_environment.models.server_env_mixin: Unable to read field FIELD_NAME in section SECTION_NAME: invalid literal for int() with base 10: ''
sebalix commented 1 year ago

/ocabot merge patch

OCA-git-bot commented 1 year ago

This PR looks fantastic, let's merge it! Prepared branch 14.0-ocabot-merge-pr-116-by-sebalix-bump-patch, awaiting test results.

OCA-git-bot commented 1 year ago

Congratulations, your PR was merged at a878ff0a0ab8337e2549475b0d9d4f49b519f704. Thanks a lot for contributing to OCA. ❤️