OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google 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 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 19 matching lines...) Loading... |
30 | 30 |
31 #include "core/dom/ExceptionCode.h" | 31 #include "core/dom/ExceptionCode.h" |
32 | 32 |
33 namespace blink { | 33 namespace blink { |
34 | 34 |
35 static const struct CoreException { | 35 static const struct CoreException { |
36 const char* const name; | 36 const char* const name; |
37 const char* const message; | 37 const char* const message; |
38 const int code; | 38 const int code; |
39 } coreExceptions[] = { | 39 } coreExceptions[] = { |
| 40 // This list must be kept in sync with the one in ExceptionCode.h |
40 { "IndexSizeError", "Index or size was negative, or greater than the allowed
value.", 1 }, | 41 { "IndexSizeError", "Index or size was negative, or greater than the allowed
value.", 1 }, |
41 { "HierarchyRequestError", "A Node was inserted somewhere it doesn't belong.
", 3 }, | 42 { "HierarchyRequestError", "A Node was inserted somewhere it doesn't belong.
", 3 }, |
42 { "WrongDocumentError", "A Node was used in a different document than the on
e that created it (that doesn't support it).", 4 }, | 43 { "WrongDocumentError", "A Node was used in a different document than the on
e that created it (that doesn't support it).", 4 }, |
43 { "InvalidCharacterError", "The string contains invalid characters.", 5 }, | 44 { "InvalidCharacterError", "The string contains invalid characters.", 5 }, |
44 { "NoModificationAllowedError", "An attempt was made to modify an object whe
re modifications are not allowed.", 7 }, | 45 { "NoModificationAllowedError", "An attempt was made to modify an object whe
re modifications are not allowed.", 7 }, |
45 { "NotFoundError", "An attempt was made to reference a Node in a context whe
re it does not exist.", 8 }, | 46 { "NotFoundError", "An attempt was made to reference a Node in a context whe
re it does not exist.", 8 }, |
46 { "NotSupportedError", "The implementation did not support the requested typ
e of object or operation.", 9 }, | 47 { "NotSupportedError", "The implementation did not support the requested typ
e of object or operation.", 9 }, |
47 { "InUseAttributeError", "An attempt was made to add an attribute that is al
ready in use elsewhere.", 10 }, | 48 { "InUseAttributeError", "An attempt was made to add an attribute that is al
ready in use elsewhere.", 10 }, |
48 { "InvalidStateError", "An attempt was made to use an object that is not, or
is no longer, usable.", 11 }, | 49 { "InvalidStateError", "An attempt was made to use an object that is not, or
is no longer, usable.", 11 }, |
49 { "SyntaxError", "An invalid or illegal string was specified.", 12 }, | 50 { "SyntaxError", "An invalid or illegal string was specified.", 12 }, |
(...skipping 24 matching lines...) Loading... |
74 { "PathExistsError", "An attempt was made to create a file or directory wher
e an element already exists.", 0 }, | 75 { "PathExistsError", "An attempt was made to create a file or directory wher
e an element already exists.", 0 }, |
75 | 76 |
76 // SQL | 77 // SQL |
77 { "DatabaseError", "The operation failed for some reason related to the data
base.", 0 }, | 78 { "DatabaseError", "The operation failed for some reason related to the data
base.", 0 }, |
78 | 79 |
79 // Web Crypto | 80 // Web Crypto |
80 { "OperationError", "The operation failed for an operation-specific reason",
0 }, | 81 { "OperationError", "The operation failed for an operation-specific reason",
0 }, |
81 | 82 |
82 // Push API | 83 // Push API |
83 { "PermissionDeniedError", "User or security policy denied the request.", 0
}, | 84 { "PermissionDeniedError", "User or security policy denied the request.", 0
}, |
| 85 |
| 86 // Used by HTML and Media Session API. |
| 87 { "NotAllowedError", "The request is not allowed by the user agent or the pl
atform in the current context.", 0 }, |
84 }; | 88 }; |
85 | 89 |
86 static const CoreException* getErrorEntry(ExceptionCode ec) | 90 static const CoreException* getErrorEntry(ExceptionCode ec) |
87 { | 91 { |
88 size_t tableSize = WTF_ARRAY_LENGTH(coreExceptions); | 92 size_t tableSize = WTF_ARRAY_LENGTH(coreExceptions); |
89 size_t tableIndex = ec - IndexSizeError; | 93 size_t tableIndex = ec - IndexSizeError; |
90 | 94 |
91 return tableIndex < tableSize ? &coreExceptions[tableIndex] : 0; | 95 return tableIndex < tableSize ? &coreExceptions[tableIndex] : 0; |
92 } | 96 } |
93 | 97 |
(...skipping 54 matching lines...) Loading... |
148 { | 152 { |
149 const CoreException* entry = getErrorEntry(ec); | 153 const CoreException* entry = getErrorEntry(ec); |
150 ASSERT(entry); | 154 ASSERT(entry); |
151 if (!entry) | 155 if (!entry) |
152 return "Unknown error."; | 156 return "Unknown error."; |
153 | 157 |
154 return entry->message; | 158 return entry->message; |
155 } | 159 } |
156 | 160 |
157 } // namespace blink | 161 } // namespace blink |
OLD | NEW |