OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python2.4 |
| 2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 '''Exception types for GRIT. |
| 7 ''' |
| 8 |
| 9 class Base(Exception): |
| 10 '''A base exception that uses the class's docstring in addition to any |
| 11 user-provided message as the body of the Base. |
| 12 ''' |
| 13 def __init__(self, msg=''): |
| 14 if len(msg): |
| 15 if self.__doc__: |
| 16 msg = self.__doc__ + ': ' + msg |
| 17 else: |
| 18 msg = self.__doc__ |
| 19 Exception.__init__(self, msg) |
| 20 |
| 21 |
| 22 class Parsing(Base): |
| 23 '''An error occurred parsing a GRD or XTB file.''' |
| 24 def __init__(self, msg=''): |
| 25 Base.__init__(self, msg) |
| 26 |
| 27 |
| 28 class UnknownElement(Parsing): |
| 29 '''An unknown node type was encountered.''' |
| 30 def __init__(self, msg=''): |
| 31 Parsing.__init__(self, msg) |
| 32 |
| 33 |
| 34 class MissingElement(Parsing): |
| 35 '''An expected element was missing.''' |
| 36 def __init__(self, msg=''): |
| 37 Parsing.__init__(self, msg) |
| 38 |
| 39 |
| 40 class UnexpectedChild(Parsing): |
| 41 '''An unexpected child element was encountered (on a leaf node).''' |
| 42 def __init__(self, msg=''): |
| 43 Parsing.__init__(self, msg) |
| 44 |
| 45 |
| 46 class UnexpectedAttribute(Parsing): |
| 47 '''The attribute was not expected''' |
| 48 def __init__(self, msg=''): |
| 49 Parsing.__init__(self, msg) |
| 50 |
| 51 |
| 52 class UnexpectedContent(Parsing): |
| 53 '''This element should not have content''' |
| 54 def __init__(self, msg=''): |
| 55 Parsing.__init__(self, msg) |
| 56 |
| 57 |
| 58 class MissingMandatoryAttribute(Parsing): |
| 59 '''This element is missing a mandatory attribute''' |
| 60 def __init__(self, msg=''): |
| 61 Parsing.__init__(self, msg) |
| 62 |
| 63 |
| 64 class MutuallyExclusiveMandatoryAttribute(Parsing): |
| 65 '''This element has 2 mutually exclusive mandatory attributes''' |
| 66 def __init__(self, msg=''): |
| 67 Parsing.__init__(self, msg) |
| 68 |
| 69 |
| 70 class DuplicateKey(Parsing): |
| 71 '''A duplicate key attribute was found.''' |
| 72 def __init__(self, msg=''): |
| 73 Parsing.__init__(self, msg) |
| 74 |
| 75 |
| 76 class TooManyExamples(Parsing): |
| 77 '''Only one <ex> element is allowed for each <ph> element.''' |
| 78 def __init__(self, msg=''): |
| 79 Parsing.__init__(self, msg) |
| 80 |
| 81 |
| 82 class GotPathExpectedFilenameOnly(Parsing): |
| 83 '''The 'filename' attribute of an <output> node must not be a path, only |
| 84 a filename. |
| 85 ''' |
| 86 def __init__(self, msg=''): |
| 87 Parsing.__init__(self, msg) |
| 88 |
| 89 |
| 90 class InvalidMessage(Base): |
| 91 '''The specified message failed validation.''' |
| 92 def __init__(self, msg=''): |
| 93 Base.__init__(self, msg) |
| 94 |
| 95 |
| 96 class InvalidTranslation(Base): |
| 97 '''Attempt to add an invalid translation to a clique.''' |
| 98 def __init__(self, msg=''): |
| 99 Base.__init__(self, msg) |
| 100 |
| 101 |
| 102 class NoSuchTranslation(Base): |
| 103 '''Requested translation not available''' |
| 104 def __init__(self, msg=''): |
| 105 Base.__init__(self, msg) |
| 106 |
| 107 |
| 108 class NotReady(Base): |
| 109 '''Attempt to use an object before it is ready, or attempt to translate |
| 110 an empty document.''' |
| 111 def __init__(self, msg=''): |
| 112 Base.__init__(self, msg) |
| 113 |
| 114 |
| 115 class TooManyPlaceholders(Base): |
| 116 '''Too many placeholders for elements of the same type.''' |
| 117 def __init__(self, msg=''): |
| 118 Base.__init__(self, msg) |
| 119 |
| 120 |
| 121 class MismatchingPlaceholders(Base): |
| 122 '''Placeholders do not match.''' |
| 123 def __init__(self, msg=''): |
| 124 Base.__init__(self, msg) |
| 125 |
| 126 |
| 127 class InvalidPlaceholderName(Base): |
| 128 '''Placeholder name can only contain A-Z, a-z, 0-9 and underscore.''' |
| 129 def __init__(self, msg=''): |
| 130 Base.__init__(self, msg) |
| 131 |
| 132 |
| 133 class BlockTagInTranslateableChunk(Base): |
| 134 '''A block tag was encountered where it wasn't expected.''' |
| 135 def __init__(self, msg=''): |
| 136 Base.__init__(self, msg) |
| 137 |
| 138 |
| 139 class SectionNotFound(Base): |
| 140 '''The section you requested was not found in the RC file. Make |
| 141 sure the section ID is correct (matches the section's ID in the RC file). |
| 142 Also note that you may need to specify the RC file's encoding (using the |
| 143 encoding="" attribute) if it is not in the default Windows-1252 encoding. |
| 144 ''' |
| 145 def __init__(self, msg=''): |
| 146 Base.__init__(self, msg) |
| 147 |
| 148 |
| 149 class IdRangeOverlap(Base): |
| 150 '''ID range overlap.''' |
| 151 def __init__(self, msg=''): |
| 152 Base.__init__(self, msg) |
| 153 |
OLD | NEW |