OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
11 * documentation and/or other materials provided with the distribution. | 11 * documentation and/or other materials provided with the distribution. |
12 * | 12 * |
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "ExceptionCode.h" | 27 #include "ExceptionCode.h" |
28 | 28 |
29 #include "EventException.h" | 29 #include "EventException.h" |
| 30 #include "IDBDatabaseException.h" |
30 #include "RangeException.h" | 31 #include "RangeException.h" |
31 #include "XMLHttpRequestException.h" | 32 #include "XMLHttpRequestException.h" |
32 | 33 |
33 #if ENABLE(SVG) | 34 #if ENABLE(SVG) |
34 #include "SVGException.h" | 35 #include "SVGException.h" |
35 #endif | 36 #endif |
36 | 37 |
37 #if ENABLE(XPATH) | 38 #if ENABLE(XPATH) |
38 #include "XPathException.h" | 39 #include "XPathException.h" |
39 #endif | 40 #endif |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 "An attempt was made to write to a file or directory which could not be modi
fied due to the state of the underlying filesystem.", | 203 "An attempt was made to write to a file or directory which could not be modi
fied due to the state of the underlying filesystem.", |
203 "An operation that depends on state cached in an interface object was made b
ut the state had changed since it was read from disk.", | 204 "An operation that depends on state cached in an interface object was made b
ut the state had changed since it was read from disk.", |
204 "An invalid or unsupported argument was given, like an invalid line ending s
pecifier.", | 205 "An invalid or unsupported argument was given, like an invalid line ending s
pecifier.", |
205 "The modification request was illegal.", | 206 "The modification request was illegal.", |
206 "The operation failed because it would cause the application to exceed its s
torage quota.", | 207 "The operation failed because it would cause the application to exceed its s
torage quota.", |
207 "The path supplied exists, but was not an entry of requested type.", | 208 "The path supplied exists, but was not an entry of requested type.", |
208 "An attempt was made to create a file or directory where an element already
exists." | 209 "An attempt was made to create a file or directory where an element already
exists." |
209 }; | 210 }; |
210 #endif | 211 #endif |
211 | 212 |
| 213 #if ENABLE(INDEXED_DATABASE) |
| 214 static const char* const idbDatabaseExceptionNames[] = { |
| 215 "UNKNOWN_ERR", |
| 216 "NON_TRANSIENT_ERR", |
| 217 "NOT_FOUND_ERR", |
| 218 "CONSTRAINT_ERR", |
| 219 "DATA_ERR", |
| 220 "NOT_ALLOWED_ERR", |
| 221 "SERIAL_ERR", |
| 222 "RECOVERABLE_ERR", |
| 223 "TRANSIENT_ERR", |
| 224 "TIMEOUT_ERR", |
| 225 "DEADLOCK_ERR" |
| 226 }; |
| 227 |
| 228 static const char* const idbDatabaseExceptionDescriptions[] = { |
| 229 "An unknown error occurred within Indexed Database.", |
| 230 "NON_TRANSIENT_ERR", // FIXME: Write a better message if it's ever possible
this is thrown. |
| 231 "The name supplied does not match any existing item.", |
| 232 "The request cannot be completed due to a failed constraint.", |
| 233 "The data provided does not meet the requirements of the function.", |
| 234 "This function is not allowed to be called in such a context.", |
| 235 "The data supplied cannot be serialized according to the structured cloning
algorithm.", |
| 236 "RECOVERABLE_ERR", // FIXME: This isn't even used. |
| 237 "TRANSIENT_ERR", // FIXME: This isn't even used. |
| 238 "TIMEOUT_ERR", // This can't be thrown. |
| 239 "DEADLOCK_ERR" // This can't be thrown. |
| 240 }; |
| 241 #endif |
| 242 |
212 void getExceptionCodeDescription(ExceptionCode ec, ExceptionCodeDescription& des
cription) | 243 void getExceptionCodeDescription(ExceptionCode ec, ExceptionCodeDescription& des
cription) |
213 { | 244 { |
214 ASSERT(ec); | 245 ASSERT(ec); |
215 | 246 |
216 const char* typeName; | 247 const char* typeName; |
217 int code = ec; | 248 int code = ec; |
218 const char* const* nameTable; | 249 const char* const* nameTable; |
219 const char* const* descriptionTable; | 250 const char* const* descriptionTable; |
220 int nameTableSize; | 251 int nameTableSize; |
221 int nameTableOffset; | 252 int nameTableOffset; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 #if ENABLE(BLOB) || ENABLE(FILE_SYSTEM) | 311 #if ENABLE(BLOB) || ENABLE(FILE_SYSTEM) |
281 } else if (code >= FileException::FileExceptionOffset && code <= FileExcepti
on::FileExceptionMax) { | 312 } else if (code >= FileException::FileExceptionOffset && code <= FileExcepti
on::FileExceptionMax) { |
282 type = FileExceptionType; | 313 type = FileExceptionType; |
283 typeName = "DOM File"; | 314 typeName = "DOM File"; |
284 code -= FileException::FileExceptionOffset; | 315 code -= FileException::FileExceptionOffset; |
285 nameTable = fileExceptionNames; | 316 nameTable = fileExceptionNames; |
286 descriptionTable = fileExceptionDescriptions; | 317 descriptionTable = fileExceptionDescriptions; |
287 nameTableSize = WTF_ARRAY_LENGTH(fileExceptionNames); | 318 nameTableSize = WTF_ARRAY_LENGTH(fileExceptionNames); |
288 nameTableOffset = FileException::NOT_FOUND_ERR; | 319 nameTableOffset = FileException::NOT_FOUND_ERR; |
289 #endif | 320 #endif |
| 321 #if ENABLE(INDEXED_DATABASE) |
| 322 } else if (code >= IDBDatabaseException::IDBDatabaseExceptionOffset && code
<= IDBDatabaseException::IDBDatabaseExceptionMax) { |
| 323 type = IDBDatabaseExceptionType; |
| 324 typeName = "DOM IDBDatabase"; |
| 325 code -= IDBDatabaseException::IDBDatabaseExceptionOffset; |
| 326 nameTable = idbDatabaseExceptionNames; |
| 327 descriptionTable = idbDatabaseExceptionDescriptions; |
| 328 nameTableSize = WTF_ARRAY_LENGTH(idbDatabaseExceptionNames); |
| 329 nameTableOffset = IDBDatabaseException::UNKNOWN_ERR; |
| 330 #endif |
290 } else { | 331 } else { |
291 type = DOMExceptionType; | 332 type = DOMExceptionType; |
292 typeName = "DOM"; | 333 typeName = "DOM"; |
293 nameTable = exceptionNames; | 334 nameTable = exceptionNames; |
294 descriptionTable = exceptionDescriptions; | 335 descriptionTable = exceptionDescriptions; |
295 nameTableSize = WTF_ARRAY_LENGTH(exceptionNames); | 336 nameTableSize = WTF_ARRAY_LENGTH(exceptionNames); |
296 nameTableOffset = INDEX_SIZE_ERR; | 337 nameTableOffset = INDEX_SIZE_ERR; |
297 } | 338 } |
298 | 339 |
299 description.typeName = typeName; | 340 description.typeName = typeName; |
300 description.name = (ec >= nameTableOffset && ec - nameTableOffset < nameTabl
eSize) ? nameTable[ec - nameTableOffset] : 0; | 341 description.name = (ec >= nameTableOffset && ec - nameTableOffset < nameTabl
eSize) ? nameTable[ec - nameTableOffset] : 0; |
301 description.description = (ec >= nameTableOffset && ec - nameTableOffset < n
ameTableSize) ? descriptionTable[ec - nameTableOffset] : 0; | 342 description.description = (ec >= nameTableOffset && ec - nameTableOffset < n
ameTableSize) ? descriptionTable[ec - nameTableOffset] : 0; |
302 description.code = code; | 343 description.code = code; |
303 description.type = type; | 344 description.type = type; |
304 | 345 |
305 // All exceptions used in the DOM code should have names. | 346 // All exceptions used in the DOM code should have names. |
306 ASSERT(description.name); | 347 ASSERT(description.name); |
307 ASSERT(description.description); | 348 ASSERT(description.description); |
308 } | 349 } |
309 | 350 |
310 } // namespace WebCore | 351 } // namespace WebCore |
OLD | NEW |