paul@6 | 1 | #!/usr/bin/env python |
paul@6 | 2 | |
paul@6 | 3 | """ |
paul@470 | 4 | Base exception objects. See __builtins__.core for the core exceptions. |
paul@6 | 5 | |
paul@868 | 6 | Copyright (C) 2015, 2016, 2018, 2019 Paul Boddie <paul@boddie.org.uk> |
paul@6 | 7 | |
paul@6 | 8 | This program is free software; you can redistribute it and/or modify it under |
paul@6 | 9 | the terms of the GNU General Public License as published by the Free Software |
paul@6 | 10 | Foundation; either version 3 of the License, or (at your option) any later |
paul@6 | 11 | version. |
paul@6 | 12 | |
paul@6 | 13 | This program is distributed in the hope that it will be useful, but WITHOUT |
paul@6 | 14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@6 | 15 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@6 | 16 | details. |
paul@6 | 17 | |
paul@6 | 18 | You should have received a copy of the GNU General Public License along with |
paul@6 | 19 | this program. If not, see <http://www.gnu.org/licenses/>. |
paul@6 | 20 | """ |
paul@6 | 21 | |
paul@470 | 22 | class LookupError(Exception): |
paul@470 | 23 | |
paul@470 | 24 | "A general lookup error." |
paul@470 | 25 | |
paul@470 | 26 | pass |
paul@470 | 27 | |
paul@470 | 28 | class IndexError(LookupError): |
paul@262 | 29 | |
paul@262 | 30 | "An error condition involving an index." |
paul@262 | 31 | |
paul@821 | 32 | def __init__(self, .index): |
paul@821 | 33 | |
paul@821 | 34 | "Initialise the exception with the given 'index'." |
paul@821 | 35 | |
paul@821 | 36 | pass |
paul@262 | 37 | |
paul@470 | 38 | class KeyError(LookupError): |
paul@288 | 39 | |
paul@288 | 40 | "An error concerned with a dictionary key." |
paul@288 | 41 | |
paul@821 | 42 | def __init__(self, .key): |
paul@821 | 43 | |
paul@821 | 44 | "Initialise the exception with the given 'key'." |
paul@821 | 45 | |
paul@821 | 46 | pass |
paul@288 | 47 | |
paul@470 | 48 | class RuntimeError(Exception): |
paul@470 | 49 | |
paul@470 | 50 | "A general runtime error." |
paul@470 | 51 | |
paul@470 | 52 | pass |
paul@470 | 53 | |
paul@470 | 54 | class NotImplementedError(RuntimeError): |
paul@468 | 55 | |
paul@468 | 56 | "An error indicating an unimplemented function or method." |
paul@468 | 57 | |
paul@821 | 58 | def __init__(self, .name): |
paul@821 | 59 | |
paul@821 | 60 | "Initialise the exception with the given 'name'." |
paul@821 | 61 | |
paul@821 | 62 | pass |
paul@468 | 63 | |
paul@868 | 64 | class LoopExit(Exception): |
paul@868 | 65 | |
paul@868 | 66 | "An exception signalling the end of iteration in a loop." |
paul@868 | 67 | |
paul@868 | 68 | pass |
paul@868 | 69 | |
paul@468 | 70 | class StopIteration(Exception): |
paul@468 | 71 | |
paul@468 | 72 | "An exception signalling the end of iteration." |
paul@468 | 73 | |
paul@468 | 74 | pass |
paul@281 | 75 | |
paul@281 | 76 | class ValueError(Exception): |
paul@281 | 77 | |
paul@281 | 78 | "An error concerned with a particular value." |
paul@281 | 79 | |
paul@821 | 80 | def __init__(self, .value): |
paul@821 | 81 | |
paul@821 | 82 | "Initialise the exception with the given 'value'." |
paul@821 | 83 | |
paul@821 | 84 | pass |
paul@6 | 85 | |
paul@6 | 86 | # vim: tabstop=4 expandtab shiftwidth=4 |