|
1 # pylint: disable-msg=W0401,W0614 |
|
2 """exceptions used in the core of the CubicWeb web application |
|
3 |
|
4 :organization: Logilab |
|
5 :copyright: 2001-2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved. |
|
6 :contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr |
|
7 """ |
|
8 __docformat__ = "restructuredtext en" |
|
9 |
|
10 from cubicweb._exceptions import * |
|
11 |
|
12 class PublishException(CubicWebException): |
|
13 """base class for publishing related exception""" |
|
14 |
|
15 class RequestError(PublishException): |
|
16 """raised when a request can't be served because of a bad input""" |
|
17 |
|
18 class NothingToEdit(RequestError): |
|
19 """raised when an edit request doesn't specify any eid to edit""" |
|
20 |
|
21 class NotFound(RequestError): |
|
22 """raised when a 404 error should be returned""" |
|
23 |
|
24 class Redirect(PublishException): |
|
25 """raised to redirect the http request""" |
|
26 def __init__(self, location): |
|
27 self.location = location |
|
28 |
|
29 class DirectResponse(Exception): |
|
30 def __init__(self, response): |
|
31 self.response = response |
|
32 |
|
33 class StatusResponse(Exception): |
|
34 def __init__(self, status, content=''): |
|
35 self.status = int(status) |
|
36 self.content = content |
|
37 |
|
38 class ExplicitLogin(AuthenticationError): |
|
39 """raised when a bad connection id is given or when an attempt to establish |
|
40 a connection failed""" |
|
41 |
|
42 class InvalidSession(CubicWebException): |
|
43 """raised when a session id is found but associated session is not found or |
|
44 invalid |
|
45 """ |
|
46 |
|
47 class RemoteCallFailed(RequestError): |
|
48 """raised when a json remote call fails |
|
49 """ |
|
50 def __init__(self, reason=''): |
|
51 super(RequestError, self).__init__() |
|
52 self.reason = reason |
|
53 |
|
54 def dumps(self): |
|
55 import simplejson |
|
56 return simplejson.dumps({'reason': self.reason}) |
|
57 |