##// END OF EJS Templates
core: updated copyrights to 2024
core: updated copyrights to 2024

File last commit:

r1327:278da2b3 default
r1327:278da2b3 default
Show More
exceptions.py
138 lines | 4.3 KiB | text/x-python | PythonLexer
initial commit
r0 # RhodeCode VCSServer provides access to different vcs backends via network.
core: updated copyrights to 2024
r1327 # Copyright (C) 2014-2024 RhodeCode GmbH
initial commit
r0 #
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
"""
Special exception handling over the wire.
Since we cannot assume that our client is able to import our exception classes,
this module provides a "wrapping" mechanism to raise plain exceptions
which contain an extra attribute `_vcs_kind` to allow a client to distinguish
different error conditions.
"""
hooks: adjust to handle protected branch cases, and force push.
r509 from pyramid.httpexceptions import HTTPLocked, HTTPForbidden
initial commit
r0
exceptions: use new wrapper that store the org exception inside the newly generated exceptions....
r490 def _make_exception(kind, org_exc, *args):
initial commit
r0 """
Prepares a base `Exception` instance to be sent over the wire.
To give our caller a hint what this is about, it will attach an attribute
`_vcs_kind` to the exception.
"""
exc = Exception(*args)
exc._vcs_kind = kind
exceptions: use new wrapper that store the org exception inside the newly generated exceptions....
r490 exc._org_exc = org_exc
Mercurial: errors, properly expose lookup exceptions traceback.
r658 exc._org_exc_tb = getattr(org_exc, '_org_exc_tb', '')
initial commit
r0 return exc
exceptions: use new wrapper that store the org exception inside the newly generated exceptions....
r490 def AbortException(org_exc=None):
def _make_exception_wrapper(*args):
return _make_exception('abort', org_exc, *args)
return _make_exception_wrapper
initial commit
r0
exceptions: use new wrapper that store the org exception inside the newly generated exceptions....
r490 def ArchiveException(org_exc=None):
def _make_exception_wrapper(*args):
return _make_exception('archive', org_exc, *args)
return _make_exception_wrapper
initial commit
r0
exceptions: use new wrapper that store the org exception inside the newly generated exceptions....
r490 def LookupException(org_exc=None):
def _make_exception_wrapper(*args):
return _make_exception('lookup', org_exc, *args)
return _make_exception_wrapper
initial commit
r0
exceptions: use new wrapper that store the org exception inside the newly generated exceptions....
r490 def VcsException(org_exc=None):
def _make_exception_wrapper(*args):
return _make_exception('error', org_exc, *args)
return _make_exception_wrapper
initial commit
r0
core: deprecated http based callback deamon....
r1315 def LockedRepoException(org_exc=None):
exceptions: use new wrapper that store the org exception inside the newly generated exceptions....
r490 def _make_exception_wrapper(*args):
return _make_exception('repo_locked', org_exc, *args)
return _make_exception_wrapper
initial commit
r0
hooks: adjust to handle protected branch cases, and force push.
r509 def RepositoryBranchProtectedException(org_exc=None):
def _make_exception_wrapper(*args):
return _make_exception('repo_branch_protected', org_exc, *args)
return _make_exception_wrapper
core: code changes to handle branch-permissions / locking / incorrect client support
r1323 def ClientNotSupportedException(org_exc=None):
def _make_exception_wrapper(*args):
return _make_exception('client_not_supported', org_exc, *args)
return _make_exception_wrapper
hooks: adjust to handle protected branch cases, and force push.
r509
exceptions: use new wrapper that store the org exception inside the newly generated exceptions....
r490 def RequirementException(org_exc=None):
def _make_exception_wrapper(*args):
return _make_exception('requirement', org_exc, *args)
return _make_exception_wrapper
initial commit
r0
exceptions: use new wrapper that store the org exception inside the newly generated exceptions....
r490 def UnhandledException(org_exc=None):
def _make_exception_wrapper(*args):
return _make_exception('unhandled', org_exc, *args)
return _make_exception_wrapper
initial commit
r0
exceptions: use new wrapper that store the org exception inside the newly generated exceptions....
r490 def URLError(org_exc=None):
def _make_exception_wrapper(*args):
return _make_exception('url_error', org_exc, *args)
return _make_exception_wrapper
Martin Bornhold
http: Add error handling for the repo-locked exception. Part of #4237...
r85
exceptions: use new wrapper that store the org exception inside the newly generated exceptions....
r490
def SubrepoMergeException(org_exc=None):
def _make_exception_wrapper(*args):
return _make_exception('subrepo_merge_error', org_exc, *args)
return _make_exception_wrapper
Martin Bornhold
subrepo: Add custom exception to indicate subrepo merge conflict.
r98
Martin Bornhold
http: Add error handling for the repo-locked exception. Part of #4237...
r85
class HTTPRepoLocked(HTTPLocked):
"""
Subclass of HTTPLocked response that allows to set the title and status
code via constructor arguments.
"""
def __init__(self, title, status_code=None, **kwargs):
self.code = status_code or HTTPLocked.code
self.title = title
python3: fixes and code optimization for python3.11
r1114 super().__init__(**kwargs)
hooks: adjust to handle protected branch cases, and force push.
r509
core: code changes to handle branch-permissions / locking / incorrect client support
r1323 class HTTPRepoBranchProtected(HTTPLocked):
def __init__(self, title, status_code=None, **kwargs):
self.code = status_code or HTTPLocked.code
self.title = title
super().__init__(**kwargs)
class HTTPClientNotSupported(HTTPLocked):
def __init__(self, title, status_code=None, **kwargs):
self.code = status_code or HTTPLocked.code
self.title = title
super().__init__(**kwargs)
exceptions: don't report lookup errors as exceptions stored in the exception store....
r843
class RefNotFoundException(KeyError):
pass
archive: implemented efficient way to perform archive for each repository.
r894
class NoContentException(ValueError):
pass