OLD | NEW |
| (Empty) |
1 #!/usr/bin/env python | |
2 # Copyright (c) 2012 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 super(Base, self).__init__(msg) | |
20 | |
21 | |
22 class Parsing(Base): | |
23 '''An error occurred parsing a GRD or XTB file.''' | |
24 pass | |
25 | |
26 | |
27 class UnknownElement(Parsing): | |
28 '''An unknown node type was encountered.''' | |
29 pass | |
30 | |
31 | |
32 class MissingElement(Parsing): | |
33 '''An expected element was missing.''' | |
34 pass | |
35 | |
36 | |
37 class UnexpectedChild(Parsing): | |
38 '''An unexpected child element was encountered (on a leaf node).''' | |
39 pass | |
40 | |
41 | |
42 class UnexpectedAttribute(Parsing): | |
43 '''The attribute was not expected''' | |
44 pass | |
45 | |
46 | |
47 class UnexpectedContent(Parsing): | |
48 '''This element should not have content''' | |
49 pass | |
50 | |
51 | |
52 class MissingMandatoryAttribute(Parsing): | |
53 '''This element is missing a mandatory attribute''' | |
54 pass | |
55 | |
56 | |
57 class MutuallyExclusiveMandatoryAttribute(Parsing): | |
58 '''This element has 2 mutually exclusive mandatory attributes''' | |
59 pass | |
60 | |
61 | |
62 class DuplicateKey(Parsing): | |
63 '''A duplicate key attribute was found.''' | |
64 pass | |
65 | |
66 | |
67 class TooManyExamples(Parsing): | |
68 '''Only one <ex> element is allowed for each <ph> element.''' | |
69 pass | |
70 | |
71 | |
72 class GotPathExpectedFilenameOnly(Parsing): | |
73 '''The 'filename' attribute of <output> and the 'file' attribute of <part> | |
74 must be bare filenames, not paths. | |
75 ''' | |
76 pass | |
77 | |
78 | |
79 class FileNotFound(Parsing): | |
80 '''The resource file was not found. | |
81 ''' | |
82 pass | |
83 | |
84 | |
85 class InvalidMessage(Base): | |
86 '''The specified message failed validation.''' | |
87 pass | |
88 | |
89 | |
90 class InvalidTranslation(Base): | |
91 '''Attempt to add an invalid translation to a clique.''' | |
92 pass | |
93 | |
94 | |
95 class NoSuchTranslation(Base): | |
96 '''Requested translation not available''' | |
97 pass | |
98 | |
99 | |
100 class NotReady(Base): | |
101 '''Attempt to use an object before it is ready, or attempt to translate | |
102 an empty document.''' | |
103 pass | |
104 | |
105 | |
106 class TooManyPlaceholders(Base): | |
107 '''Too many placeholders for elements of the same type.''' | |
108 pass | |
109 | |
110 | |
111 class MismatchingPlaceholders(Base): | |
112 '''Placeholders do not match.''' | |
113 pass | |
114 | |
115 | |
116 class InvalidPlaceholderName(Base): | |
117 '''Placeholder name can only contain A-Z, a-z, 0-9 and underscore.''' | |
118 pass | |
119 | |
120 | |
121 class BlockTagInTranslateableChunk(Base): | |
122 '''A block tag was encountered where it wasn't expected.''' | |
123 pass | |
124 | |
125 | |
126 class SectionNotFound(Base): | |
127 '''The section you requested was not found in the RC file. Make | |
128 sure the section ID is correct (matches the section's ID in the RC file). | |
129 Also note that you may need to specify the RC file's encoding (using the | |
130 encoding="" attribute) if it is not in the default Windows-1252 encoding. | |
131 ''' | |
132 pass | |
133 | |
134 | |
135 class IdRangeOverlap(Base): | |
136 '''ID range overlap.''' | |
137 pass | |
138 | |
OLD | NEW |