Mercurial > kallithea
changeset 8281:5661a603cf50
cleanup: improve exception logging from validators
There were no point in logging the whole raw exception with stacktrace - it is
more relevant to log something helpful
Catching of Exception is however bad.
Also, it seems odd what ValidPerms is doing with "update permissions" in the
validator.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Fri, 06 Mar 2020 18:47:29 +0100 |
parents | 37ec17c1344c |
children | 352056907cfd |
files | kallithea/model/validators.py |
diffstat | 1 files changed, 4 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/model/validators.py Sun Mar 01 21:29:40 2020 +0100 +++ b/kallithea/model/validators.py Fri Mar 06 18:47:29 2020 +0100 @@ -409,8 +409,8 @@ if url and url != value.get('clone_uri_hidden'): try: is_valid_repo_uri(repo_type, url, make_ui()) - except Exception: - log.exception('URL validation failed') + except Exception as e: + log.warning('validation of clone URL %r failed: %s', url, e) msg = self.message('clone_uri', state) raise formencode.Invalid(msg, value, state, error_dict=dict(clone_uri=msg) @@ -588,8 +588,8 @@ .filter(UserGroup.users_group_active == True) \ .filter(UserGroup.users_group_name == k).one() - except Exception: - log.exception('Updated permission failed') + except Exception as e: + log.warning('Error validating %s permission %s', t, k) msg = self.message('perm_new_member_type', state) raise formencode.Invalid(msg, value, state, error_dict=dict(perm_new_member_name=msg)