paul@39 | 1 | #!/usr/bin/env python |
paul@39 | 2 | |
paul@39 | 3 | """ |
paul@39 | 4 | Common classes. |
paul@39 | 5 | |
paul@39 | 6 | Copyright (C) 2007, 2008 Paul Boddie <paul@boddie.org.uk> |
paul@39 | 7 | |
paul@39 | 8 | This program is free software; you can redistribute it and/or modify it under |
paul@39 | 9 | the terms of the GNU General Public License as published by the Free Software |
paul@39 | 10 | Foundation; either version 3 of the License, or (at your option) any later |
paul@39 | 11 | version. |
paul@39 | 12 | |
paul@39 | 13 | This program is distributed in the hope that it will be useful, but WITHOUT |
paul@39 | 14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@39 | 15 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@39 | 16 | details. |
paul@39 | 17 | |
paul@39 | 18 | You should have received a copy of the GNU General Public License along with |
paul@39 | 19 | this program. If not, see <http://www.gnu.org/licenses/>. |
paul@39 | 20 | """ |
paul@39 | 21 | |
paul@39 | 22 | class ProcessingError(Exception): |
paul@39 | 23 | |
paul@39 | 24 | "A processing error." |
paul@39 | 25 | |
paul@63 | 26 | pass |
paul@63 | 27 | |
paul@63 | 28 | class NodeProcessingError(ProcessingError): |
paul@63 | 29 | |
paul@63 | 30 | "A processing error associated with a particular program node." |
paul@63 | 31 | |
paul@39 | 32 | def __init__(self, unit_name, node, message): |
paul@39 | 33 | self.unit_name = unit_name |
paul@39 | 34 | self.node = node |
paul@39 | 35 | self.message = message |
paul@39 | 36 | |
paul@39 | 37 | def __repr__(self): |
paul@58 | 38 | return "Error in %r at line %d: %s" % (self.unit_name, self.node.lineno, self.message) |
paul@39 | 39 | |
paul@39 | 40 | def __str__(self): |
paul@39 | 41 | return repr(self) |
paul@39 | 42 | |
paul@39 | 43 | # vim: tabstop=4 expandtab shiftwidth=4 |