1 # This file is part of Indico.
2 # Copyright (C) 2002 - 2015 European Organization for Nuclear Research (CERN).
4 # Indico is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU General Public License as
6 # published by the Free Software Foundation; either version 3 of the
7 # License, or (at your option) any later version.
9 # Indico is distributed in the hope that it will be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with Indico; if not, see <http://www.gnu.org/licenses/>.
18 Module containing the MaKaC exception class hierarchy
21 from MaKaC
.common
.fossilize
import fossilizes
, Fossilizable
22 from indico
.core
.fossils
.errors
import IErrorReportFossil
, IErrorNoReportFossil
23 from indico
.util
.translations
import ensure_str
26 class MaKaCError(Exception, Fossilizable
):
28 fossilizes(IErrorReportFossil
)
30 def __init__(self
, msg
="", area
="", explanation
=None):
33 self
._explanation
= explanation
41 return "%s - %s" % (self
._area
, self
._msg
)
48 def getExplanation(self
):
50 Some extra information, like actions that can be taken
53 return self
._explanation
56 class AccessControlError(MaKaCError
):
60 fossilizes(IErrorNoReportFossil
)
62 def __init__(self
, objectType
="object"):
63 MaKaCError
.__init
__(self
)
64 self
.objType
= objectType
68 return _("you are not authorised to access this %s") % self
.objType
74 class ConferenceClosedError(MaKaCError
):
77 fossilizes(IErrorNoReportFossil
)
79 def __init__(self
, conf
):
80 MaKaCError
.__init
__(self
)
85 return _("the event has been closed")
88 class AccessError(AccessControlError
):
94 class KeyAccessError(AccessControlError
):
100 class ModificationError(AccessControlError
):
106 return _("you are not authorised to modify this %s") % self
.objType
109 class AdminError(AccessControlError
):
115 return _("only administrators can access this %s") % self
.objType
118 class TimingError(MaKaCError
):
123 fossilizes(IErrorNoReportFossil
)
126 class ParentTimingError(TimingError
):
132 class EntryTimingError(TimingError
):
138 class UserError(MaKaCError
):
147 return _("Error creating user")
150 class NotLoggedError(MaKaCError
):
153 fossilizes(IErrorNoReportFossil
)
156 class FormValuesError(MaKaCError
):
159 fossilizes(IErrorNoReportFossil
)
162 class NoReportError(MaKaCError
):
165 fossilizes(IErrorNoReportFossil
)
168 class NotFoundError(MaKaCError
):
170 MaKaC's own NotFound version (just for legacy support)
172 fossilizes(IErrorNoReportFossil
)
174 def __init__(self
, message
, title
=""):
178 super(NotFoundError
, self
).__init
__(title
, explanation
=message
)
181 class HtmlForbiddenTag(MaKaCError
):
187 class BadRefererError(MaKaCError
):