##// END OF EJS Templates
dependencies: bumped webob to 1.7.4 to support full chunked encoding.
dependencies: bumped webob to 1.7.4 to support full chunked encoding.

File last commit:

r149:771d647d default
r331:82032cb4 stable
Show More
exceptions.py
70 lines | 2.4 KiB | text/x-python | PythonLexer
initial commit
r0 # RhodeCode VCSServer provides access to different vcs backends via network.
license: updated copyright year to 2017
r149 # Copyright (C) 2014-2017 RodeCode 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.
"""
import functools
Martin Bornhold
http: Add error handling for the repo-locked exception. Part of #4237...
r85 from pyramid.httpexceptions import HTTPLocked
initial commit
r0
def _make_exception(kind, *args):
"""
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
return exc
AbortException = functools.partial(_make_exception, 'abort')
ArchiveException = functools.partial(_make_exception, 'archive')
LookupException = functools.partial(_make_exception, 'lookup')
VcsException = functools.partial(_make_exception, 'error')
RepositoryLockedException = functools.partial(_make_exception, 'repo_locked')
RequirementException = functools.partial(_make_exception, 'requirement')
UnhandledException = functools.partial(_make_exception, 'unhandled')
URLError = functools.partial(_make_exception, 'url_error')
Martin Bornhold
http: Add error handling for the repo-locked exception. Part of #4237...
r85
Martin Bornhold
subrepo: Add custom exception to indicate subrepo merge conflict.
r98 SubrepoMergeException = functools.partial(_make_exception, 'subrepo_merge_error')
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
super(HTTPRepoLocked, self).__init__(**kwargs)