Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemath
GitHub Repository: sagemath/sagesmc
Path: blob/master/src/sage/dev/trac_error.py
8815 views
1
r"""
2
Errors related to trac access
3
4
This module provides exception classes to report errors in trac sessions via
5
:class:`trac_interface.TracInterface`.
6
7
AUTHORS:
8
9
- Julian Rueth: initial version
10
11
"""
12
#*****************************************************************************
13
# Copyright (C) 2013 Julian Rueth <[email protected]>
14
#
15
# Distributed under the terms of the GNU General Public License (GPL)
16
# as published by the Free Software Foundation; either version 2 of
17
# the License, or (at your option) any later version.
18
# http://www.gnu.org/licenses/
19
#*****************************************************************************
20
21
class TracError(RuntimeError):
22
r"""
23
Abstract base class for an error which ocurred during a trac session.
24
25
EXAMPLES::
26
27
sage: from sage.dev.trac_error import TracError
28
sage: TracError()
29
TracError()
30
"""
31
pass
32
33
class TracConnectionError(TracError):
34
r"""
35
Trac connection error.
36
37
EXAMPLES::
38
39
sage: from sage.dev.trac_error import TracConnectionError
40
sage: TracConnectionError()
41
TracConnectionError('Connection to trac server failed.',)
42
"""
43
def __init__(self):
44
r"""
45
Initialization.
46
47
TESTS::
48
49
sage: from sage.dev.trac_error import TracConnectionError
50
sage: type(TracConnectionError())
51
<class 'sage.dev.trac_error.TracConnectionError'>
52
53
"""
54
TracError.__init__(self, "Connection to trac server failed.")
55
56
class TracAuthenticationError(TracError):
57
r"""
58
Trac authentication error.
59
60
EXAMPLES::
61
62
sage: from sage.dev.trac_error import TracAuthenticationError
63
sage: TracAuthenticationError()
64
TracAuthenticationError('Authentication with trac server failed.',)
65
"""
66
def __init__(self):
67
r"""
68
Initialization.
69
70
TESTS::
71
72
sage: from sage.dev.trac_error import TracAuthenticationError
73
sage: type(TracAuthenticationError())
74
<class 'sage.dev.trac_error.TracAuthenticationError'>
75
76
"""
77
TracError.__init__(self, "Authentication with trac server failed.")
78
79
class TracInternalError(TracError):
80
r"""
81
Error to indicate that the XML-RPC interface of trac returned an error.
82
83
EXAMPLES::
84
85
sage: from sage.dev.trac_error import TracInternalError
86
sage: import xmlrpclib
87
sage: raise TracInternalError(xmlrpclib.Fault(403,
88
....: "TICKET_CREATE privileges are required to perform this operation."
89
....: " You don't have the required permissions."))
90
Traceback (most recent call last):
91
...
92
TracInternalError: <Fault 403: "TICKET_CREATE privileges are required to
93
perform this operation. You don't have the required permissions.">
94
"""
95
def __init__(self, fault):
96
r"""
97
Initialization.
98
99
TESTS::
100
101
sage: from sage.dev.trac_error import TracInternalError
102
sage: import xmlrpclib
103
sage: type(TracInternalError(xmlrpclib.Fault(403,
104
....: "TICKET_CREATE privileges are required to perform this operation."
105
....: " You don't have the required permissions.")))
106
<class 'sage.dev.trac_error.TracInternalError'>
107
"""
108
self._fault = fault
109
self.faultCode = fault.faultCode
110
TracError.__init__(self, self._fault)
111
112