]> git.evergreen-ils.org Git - OpenSRF.git/blob - src/python/osrf/ex.py
45b3484b23a37d59424c03b33a3d330c39a61a71
[OpenSRF.git] / src / python / osrf / ex.py
1 # -----------------------------------------------------------------------
2 # Copyright (C) 2007  Georgia Public Library Service
3 # Bill Erickson <billserickson@gmail.com>
4
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14
15 #
16 # This modules define the exception classes.  In general, an 
17 # exception is little more than a name.
18 # -----------------------------------------------------------------------
19
20 class OSRFException(Exception):
21     """Root class for exceptions."""
22     def __init__(self, info=''):
23         self.msg = '%s: %s' % (self.__class__.__name__, info)
24     def __str__(self):
25         return self.msg
26
27
28 class NetworkException(OSRFException):
29     def __init__(self):
30         OSRFException.__init__('Error communicating with the OpenSRF network')
31
32 class OSRFProtocolException(OSRFException):
33     """Raised when something happens during opensrf network stack processing."""
34     pass
35
36 class OSRFServiceException(OSRFException):
37     """Raised when there was an error communicating with a remote service."""
38     pass
39
40 class OSRFConfigException(OSRFException):
41     """Invalid config option requested."""
42     pass
43
44 class OSRFNetworkObjectException(OSRFException):
45     pass
46     
47 class OSRFJSONParseException(OSRFException):
48     """Raised when a JSON parsing error occurs."""
49     pass
50