1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
/*
error.cpp
This file is part of KSieve,
the KDE internet mail/usenet news message filtering library.
Copyright (c) 2002-2003 Marc Mutz <mutz@kde.org>
KSieve is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License, version 2, as
published by the Free Software Foundation.
KSieve is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
In addition, as a special exception, the copyright holders give
permission to link the code of this program with any edition of
the TQt library by Trolltech AS, Norway (or with modified versions
of TQt that use the same license as TQt), and distribute linked
combinations including the two. You must obey the GNU General
Public License in all respects for all of the code used other than
TQt. If you modify this file, you may extend this exception to
your version of the file, but you are not obligated to do so. If
you do not wish to do so, delete this exception statement from
your version.
*/
#include <config.h>
#include <ksieve/error.h>
#include <tdelocale.h> // i18n
#include <climits> // UINT_MAX
namespace KSieve {
const char * Error::typeToString( Type t ) {
switch ( t ) {
#define CASE(x) case x: return #x
CASE( None );
CASE( Custom );
CASE( CRWithoutLF );
CASE( SlashWithoutAsterisk );
CASE( IllegalCharacter );
CASE( UnexpectedCharacter );
CASE( NoLeadingDigits );
CASE( NonCWSAfterTextColon );
CASE( NumberOutOfRange );
CASE( InvalidUTF8 );
CASE( UnfinishedBracketComment );
CASE( PrematureEndOfMultiLine );
CASE( PrematureEndOfQuotedString );
CASE( PrematureEndOfStringList );
CASE( PrematureEndOfTestList );
CASE( PrematureEndOfBlock );
CASE( MissingWhitespace );
CASE( MissingSemicolonOrBlock );
CASE( ExpectedBlockOrSemicolon );
CASE( ExpectedCommand );
CASE( ConsecutiveCommasInStringList );
CASE( ConsecutiveCommasInTestList );
CASE( MissingCommaInTestList );
CASE( MissingCommaInStringList );
CASE( NonStringInStringList );
CASE( NonCommandInCommandList );
CASE( NonTestInTestList );
CASE( RequireNotFirst );
CASE( RequireMissingForCommand );
CASE( RequireMissingForTest );
CASE( RequireMissingForComparator );
CASE( UnsupportedCommand );
CASE( UnsupportedTest );
CASE( UnsupportedComparator );
CASE( TestNestingTooDeep );
CASE( BlockNestingTooDeep );
CASE( InvalidArgument );
CASE( ConflictingArguments );
CASE( ArgumentsRepeated );
CASE( CommandOrderingConstraintViolation );
CASE( IncompatibleActionsRequested );
CASE( MailLoopDetected );
CASE( TooManyActions );
#undef CASE
default:
return "<unknown>";
}
}
TQString Error::asString() const {
TQString err;
switch( type() ) {
case None:
return TQString();
case Custom:
return mStringOne;
// Parse errors:
case CRWithoutLF:
err = i18n("Parse error: Carriage Return (CR) without Line Feed (LF)");
break;
case SlashWithoutAsterisk:
err = i18n("Parse error: Unquoted Slash ('/') without Asterisk ('*'). "
"Broken Comment?");
break;
case IllegalCharacter:
err = i18n("Parse error: Illegal Character");
break;
case UnexpectedCharacter:
err = i18n("Parse error: Unexpected Character, probably a missing space?");
break;
case NoLeadingDigits:
err = i18n("Parse error: Tag Name has leading Digits");
break;
case NonCWSAfterTextColon:
err = i18n("Parse error: Only whitespace and #comments may "
"follow \"text:\" on the same line");
break;
case NumberOutOfRange:
err = i18n("Parse error: Number out of Range (must be smaller than %1)").arg(UINT_MAX);
break;
case InvalidUTF8:
err = i18n("Parse error: Invalid UTF-8 sequence");
break;
case PrematureEndOfMultiLine:
err = i18n("Parse error: Premature end of Multiline String (did you forget the '.'?)");
break;
case PrematureEndOfQuotedString:
err = i18n("Parse error: Premature end of Quoted String (missing closing '\"')");
break;
case PrematureEndOfStringList:
err = i18n("Parse error: Premature end of String List (missing closing ']')");
break;
case PrematureEndOfTestList:
err = i18n("Parse error: Premature end of Test List (missing closing ')')");
break;
case PrematureEndOfBlock:
err = i18n("Parse error: Premature end of Block (missing closing '}')");
break;
case MissingWhitespace:
err = i18n("Parse error: Missing Whitespace");
break;
case MissingSemicolonOrBlock:
err = i18n("Parse error: Missing ';' or Block");
break;
case ExpectedBlockOrSemicolon:
err = i18n("Parse error: Expected ';' or '{', got something else");
break;
case ExpectedCommand:
err = i18n("Parse error: Expected Command, got something else");
break;
case ConsecutiveCommasInStringList:
err = i18n("Parse error: Trailing, Leading or Duplicate Commas in String List");
break;
case ConsecutiveCommasInTestList:
err = i18n("Parse error: Trailing, Leading or Duplicate Commas in Test List");
break;
case MissingCommaInStringList:
err = i18n("Parse error: Missing ',' between Strings in String List");
break;
case MissingCommaInTestList:
err = i18n("Parse error: Missing ',' between Tests in Test List");
break;
case NonCommandInCommandList:
err = i18n("Parse error: Expected Command, got something else");
break;
case NonStringInStringList:
err = i18n("Parse error: Only Strings allowed in String Lists");
break;
case NonTestInTestList:
err = i18n("Parse error: Only Tests allowed in Test Lists");
break;
// validity errors:
case RequireNotFirst:
err = i18n("\"require\" must be first command");
break;
case RequireMissingForCommand:
err = i18n("\"require\" missing for command \"%1\"").arg(mStringOne);
break;
case RequireMissingForTest:
err = i18n("\"require\" missing for test \"%1\"").arg(mStringOne);
break;
case RequireMissingForComparator:
err = i18n("\"require\" missing for comparator \"%1\"").arg(mStringOne);
break;
case UnsupportedCommand:
err = i18n("Command \"%1\" not supported").arg(mStringOne);
break;
case UnsupportedTest:
err = i18n("Test \"%1\" not supported").arg(mStringOne);
break;
case UnsupportedComparator:
err = i18n("Comparator \"%1\" not supported").arg(mStringOne);
break;
case TestNestingTooDeep:
err = i18n("Site Policy Limit Violation: Test nesting too deep (max. %1)").arg( mStringOne.toUInt() );
break;
case BlockNestingTooDeep:
err = i18n("Site Policy Limit Violation: Block nesting too deep (max. %1)").arg( mStringOne.toUInt() );
break;
case InvalidArgument:
err = i18n("Invalid Argument \"%1\" to \"%2\"").arg(mStringOne).arg(mStringTwo);
break;
case ConflictingArguments:
err = i18n("Conflicting Arguments: \"%1\" and \"%2\"").arg(mStringOne).arg(mStringTwo);
break;
case ArgumentsRepeated:
err = i18n("Argument \"%1\" Repeated").arg(mStringOne);
break;
case CommandOrderingConstraintViolation:
err = i18n("Command \"%1\" violates command ordering constraints").arg(mStringOne);
break;
// runtime errors:
case IncompatibleActionsRequested:
err = i18n("Incompatible Actions \"%1\" and \"%2\" requested").arg(mStringOne).arg(mStringTwo);
break;
case MailLoopDetected:
err = i18n("Mail Loop detected");
break;
case TooManyActions:
err = i18n("Site Policy Limit Violation: Too many Actions requested (max. %1)").arg( mStringOne.toUInt() );
break;
default:
err = i18n("Unknown error");
break;
}
return err;
}
} // namespace KSieve
|