Catch the exception if decoding failed.
[pymailheaders.git] / exception.py
blob3364477586390375bc9b137e50b7c27604c0919b
1 #!/usr/bin/env python
3 # exception.py
4 # Copyright 2007 Neil Shi <zeegeek@gmail.com>
6 # Exception definitions
7 # This file defines all the exceptions used by pymailheaders
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 from sys import stderr
21 class Error(Exception):
22 """Normal error.
24 @note: Public member variables:
25 where
26 what
27 """
29 def __init__(self, where, what):
30 self.where = where
31 self.what = what
32 print >> stderr, ': '.join([self.where, self.what])
34 def __str__(self):
35 return ': '.join([self.where, self.what])
37 class TryAgain(Error):
38 """Network temporarily unavailable, try again."""
39 pass