~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to ivle/webapp/errors.py

  • Committer: William Grant
  • Date: 2010-02-15 05:37:50 UTC
  • Revision ID: grantw@unimelb.edu.au-20100215053750-hihmegnp8e7dshc2
Ignore test coverage files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
17
 
18
 
# Author: Will Grant
19
 
 
20
18
class HTTPError(Exception):
21
19
    '''A base class for all HTTP errors.'''
 
20
    message = None
 
21
 
 
22
    def __init__(self, message=None):
 
23
        # Only override the builtin one if it's actually specified.
 
24
        if message:
 
25
            self.message = message
22
26
 
23
27
class BadRequest(HTTPError):
24
28
    codename = 'Bad Request'
 
29
    message = 'Your browser sent a request that IVLE did not understand.'
25
30
    code = 400
26
31
 
27
32
class Unauthorized(HTTPError):
28
33
    codename = 'Unauthorized'
 
34
    message = 'You are not allowed to view this part of IVLE.'
29
35
    code = 401
30
36
 
31
37
class Forbidden(HTTPError):
32
38
    codename = 'Forbidden'
 
39
    message = 'You are not allowed to view this part of IVLE.'
33
40
    code = 403
34
41
 
35
42
class NotFound(HTTPError):
36
43
    codename = 'Not Found'
 
44
    message = 'The requested path does not exist.'
37
45
    code = 404
38
46
 
39
47
class MethodNotAllowed(HTTPError):
42
50
        super(HTTPError, self).__init__(*args, **kwargs)
43
51
 
44
52
    codename = 'Method Not Allowed'
 
53
    message = '''Your browser sent a request to IVLE using the wrong method.
 
54
This is probably a bug in IVLE; please report it to the administrators.'''
45
55
    code = 405