##// END OF EJS Templates
exceptions: use python3 compatible exception handling
marcink -
r3104:4de59e0f default
parent child Browse files
Show More
@@ -20,7 +20,9 b''
20 20
21 21
22 22 class JSONRPCBaseError(Exception):
23 pass
23 def __init__(self, message='', *args):
24 self.message = message
25 super(JSONRPCBaseError, self).__init__(message, *args)
24 26
25 27
26 28 class JSONRPCError(JSONRPCBaseError):
@@ -31,7 +33,8 b' class JSONRPCValidationError(JSONRPCBase'
31 33
32 34 def __init__(self, *args, **kwargs):
33 35 self.colander_exception = kwargs.pop('colander_exc')
34 super(JSONRPCValidationError, self).__init__(*args, **kwargs)
36 super(JSONRPCValidationError, self).__init__(
37 message=self.colander_exception, *args)
35 38
36 39
37 40 class JSONRPCForbidden(JSONRPCBaseError):
@@ -33,7 +33,7 b' from rhodecode.lib import audit_logger'
33 33 from rhodecode.lib import repo_maintenance
34 34 from rhodecode.lib.auth import HasPermissionAnyApi, HasUserGroupPermissionAnyApi
35 35 from rhodecode.lib.celerylib.utils import get_task_id
36 from rhodecode.lib.utils2 import str2bool, time_to_datetime
36 from rhodecode.lib.utils2 import str2bool, time_to_datetime, safe_str
37 37 from rhodecode.lib.ext_json import json
38 38 from rhodecode.lib.exceptions import StatusChangeOnClosedPullRequestError
39 39 from rhodecode.model.changeset_status import ChangesetStatusModel
@@ -316,7 +316,7 b' def get_repo_changeset(request, apiuser,'
316 316 try:
317 317 cs = repo.get_commit(commit_id=revision, pre_load=pre_load)
318 318 except TypeError as e:
319 raise JSONRPCError(e.message)
319 raise JSONRPCError(safe_str(e))
320 320 _cs_json = cs.__json__()
321 321 _cs_json['diff'] = build_commit_data(cs, changes_details)
322 322 if changes_details == 'full':
@@ -382,7 +382,7 b' def get_repo_changesets(request, apiuser'
382 382 commits = vcs_repo.get_commits(
383 383 start_id=start_rev, pre_load=pre_load)
384 384 except TypeError as e:
385 raise JSONRPCError(e.message)
385 raise JSONRPCError(safe_str(e))
386 386 except Exception:
387 387 log.exception('Fetching of commits failed')
388 388 raise JSONRPCError('Error occurred during commit fetching')
@@ -1433,7 +1433,7 b' def comment_commit('
1433 1433 commit_id = repo.scm_instance().get_commit(commit_id=commit_id).raw_id
1434 1434 except Exception as e:
1435 1435 log.exception('Failed to fetch commit')
1436 raise JSONRPCError(e.message)
1436 raise JSONRPCError(safe_str(e))
1437 1437
1438 1438 if isinstance(userid, Optional):
1439 1439 userid = apiuser.user_id
@@ -25,7 +25,8 b' import operator'
25 25 from pyramid.httpexceptions import HTTPFound, HTTPForbidden, HTTPBadRequest
26 26
27 27 from rhodecode.lib import helpers as h, diffs
28 from rhodecode.lib.utils2 import StrictAttributeDict, safe_int, datetime_to_time
28 from rhodecode.lib.utils2 import (
29 StrictAttributeDict, safe_int, datetime_to_time, safe_unicode)
29 30 from rhodecode.lib.vcs.exceptions import RepositoryRequirementError
30 31 from rhodecode.model import repo
31 32 from rhodecode.model import repo_group
@@ -202,7 +203,7 b' class RepoAppView(BaseAppView):'
202 203 def _handle_missing_requirements(self, error):
203 204 log.error(
204 205 'Requirements are missing for repository %s: %s',
205 self.db_repo_name, error.message)
206 self.db_repo_name, safe_unicode(error))
206 207
207 208 def _get_local_tmpl_context(self, include_app_defaults=True):
208 209 _ = self.request.translate
@@ -28,7 +28,7 b' class TestSSHWrapper(object):'
28 28 ssh_wrapper.serve(
29 29 vcs='microsoft-tfs', repo='test-repo', mode=None, user='test',
30 30 permissions={}, branch_permissions={})
31 assert exc_info.value.message == 'Unrecognised VCS: microsoft-tfs'
31 assert str(exc_info.value) == 'Unrecognised VCS: microsoft-tfs'
32 32
33 33 def test_parse_config(self, ssh_wrapper):
34 34 config = ssh_wrapper.parse_config(ssh_wrapper.ini_path)
General Comments 0
You need to be logged in to leave comments. Login now