exceptions: don't report lookup errors as exceptions stored in the exception store....
marcink -
r843:d6e71ccf default
Not Reviewed
Show More
Add another comment
TODOs: 0 unresolved 0 Resolved
COMMENTS: 0 General 0 Inline
@@ -115,3 +115,7
115 class HTTPRepoBranchProtected(HTTPForbidden):
115 class HTTPRepoBranchProtected(HTTPForbidden):
116 def __init__(self, *args, **kwargs):
116 def __init__(self, *args, **kwargs):
117 super(HTTPForbidden, self).__init__(*args, **kwargs)
117 super(HTTPForbidden, self).__init__(*args, **kwargs)
118
119
120 class RefNotFoundException(KeyError):
121 pass
@@ -697,7 +697,12
697 missing_commit_err = 'Commit {} does not exist for `{}`'.format(sha, wire['path'])
697 missing_commit_err = 'Commit {} does not exist for `{}`'.format(sha, wire['path'])
698 try:
698 try:
699 commit = repo.revparse_single(sha)
699 commit = repo.revparse_single(sha)
700 except (KeyError, ValueError) as e:
700 except KeyError:
701 # NOTE(marcink): KeyError doesn't give us any meaningful information
702 # here, we instead give something more explicit
703 e = exceptions.RefNotFoundException('SHA: %s not found', sha)
704 raise exceptions.LookupException(e)(missing_commit_err)
705 except ValueError as e:
701 raise exceptions.LookupException(e)(missing_commit_err)
706 raise exceptions.LookupException(e)(missing_commit_err)
702
707
703 is_tag = False
708 is_tag = False
@@ -719,7 +724,10
719 if branch:
724 if branch:
720 break
725 break
721 else:
726 else:
722 raise exceptions.LookupException(None)(missing_commit_err)
727 # NOTE(marcink): Empty error doesn't give us any meaningful information
728 # here, we instead give something more explicit
729 e = exceptions.RefNotFoundException('SHA: %s not found in branches', sha)
730 raise exceptions.LookupException(e)(missing_commit_err)
723
731
724 commit_id = commit.hex
732 commit_id = commit.hex
725 type_id = commit.type
733 type_id = commit.type
@@ -404,7 +404,20
404 exc_info[0] = org_exc.__class__
404 exc_info[0] = org_exc.__class__
405 exc_info[1] = org_exc
405 exc_info[1] = org_exc
406
406
407 store_exception(id(exc_info), exc_info)
407 should_store_exc = True
408 if org_exc:
409 def get_exc_fqn(_exc_obj):
410 module_name = getattr(org_exc.__class__, '__module__', 'UNKNOWN')
411 return module_name + '.' + org_exc_name
412
413 exc_fqn = get_exc_fqn(org_exc)
414
415 if exc_fqn in ['mercurial.error.RepoLookupError',
416 'vcsserver.exceptions.RefNotFoundException']:
417 should_store_exc = False
418
419 if should_store_exc:
420 store_exception(id(exc_info), exc_info)
408
421
409 tb_info = ''.join(
422 tb_info = ''.join(
410 traceback.format_exception(exc_type, exc_value, exc_traceback))
423 traceback.format_exception(exc_type, exc_value, exc_traceback))
Comments 0
You need to be logged in to leave comments. Login now