Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: Source/core/dom/DOMException.cpp

Issue 18398002: Remove IDBNotFoundError ExceptionCode (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: merge Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 20 matching lines...) Expand all
31 31
32 #include "ExceptionCode.h" 32 #include "ExceptionCode.h"
33 33
34 namespace WebCore { 34 namespace WebCore {
35 35
36 static struct CoreException { 36 static struct CoreException {
37 const char* const name; 37 const char* const name;
38 const char* const message; 38 const char* const message;
39 const int code; 39 const int code;
40 } coreExceptions[] = { 40 } coreExceptions[] = {
41 { "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 },
arv (Not doing code reviews) 2013/07/01 22:29:31 I'm tempted to use an .in file for this table and
42 { "HierarchyRequestError", "A Node was inserted somewhere it doesn't belong. ", 3 }, 42 { "HierarchyRequestError", "A Node was inserted somewhere it doesn't belong. ", 3 },
43 { "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 },
44 { "InvalidCharacterError", "An invalid or illegal character was specified, s uch as in an XML name.", 5 }, 44 { "InvalidCharacterError", "An invalid or illegal character was specified, s uch as in an XML name.", 5 },
45 { "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 },
46 { "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 },
47 { "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 },
48 { "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 },
49 { "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 },
50 { "SyntaxError", "An invalid or illegal string was specified.", 12 }, 50 { "SyntaxError", "An invalid or illegal string was specified.", 12 },
51 { "InvalidModificationError", "An attempt was made to modify the type of the underlying object.", 13 }, 51 { "InvalidModificationError", "An attempt was made to modify the type of the underlying object.", 13 },
52 { "NamespaceError", "An attempt was made to create or change an object in a way which is incorrect with regard to namespaces.", 14 }, 52 { "NamespaceError", "An attempt was made to create or change an object in a way which is incorrect with regard to namespaces.", 14 },
53 { "InvalidAccessError", "A parameter or an operation was not supported by th e underlying object.", 15 }, 53 { "InvalidAccessError", "A parameter or an operation was not supported by th e underlying object.", 15 },
54 { "TypeMismatchError", "The type of an object was incompatible with the expe cted type of the parameter associated to the object.", 17 }, 54 { "TypeMismatchError", "The type of an object was incompatible with the expe cted type of the parameter associated to the object.", 17 },
55 { "SecurityError", "An attempt was made to break through the security policy of the user agent.", 18 }, 55 { "SecurityError", "An attempt was made to break through the security policy of the user agent.", 18 },
56 { "NetworkError", "A network error occurred.", 19 }, 56 { "NetworkError", "A network error occurred.", 19 },
57 { "AbortError", "The user aborted a request.", 20 }, 57 { "AbortError", "The user aborted a request.", 20 },
58 { "URLMismatchError", "A worker global scope represented an absolute URL tha t is not equal to the resulting absolute URL.", 21 }, 58 { "URLMismatchError", "A worker global scope represented an absolute URL tha t is not equal to the resulting absolute URL.", 21 },
59 { "QuotaExceededError", "An attempt was made to add something to storage tha t exceeded the quota.", 22 }, 59 { "QuotaExceededError", "An attempt was made to add something to storage tha t exceeded the quota.", 22 },
60 { "TimeoutError", "A timeout occurred.", 23 }, 60 { "TimeoutError", "A timeout occurred.", 23 },
61 { "InvalidNodeTypeError", "The supplied node is invalid or has an invalid an cestor for this operation.", 24 }, 61 { "InvalidNodeTypeError", "The supplied node is invalid or has an invalid an cestor for this operation.", 24 },
62 { "DataCloneError", "An object could not be cloned.", 25 }, 62 { "DataCloneError", "An object could not be cloned.", 25 },
63 63
64 // These are IDB-specific errors. 64 // Indexed DB
65 // FIXME: NotFoundError is duplicated to have a more specific error message.
66 // https://code.google.com/p/chromium/issues/detail?id=252233
67 { "NotFoundError", "An operation failed because the requested database objec t could not be found.", 8 },
68
69 // More IDB-specific errors.
70 { "UnknownError", "An unknown error occurred within Indexed Database.", 0 }, 65 { "UnknownError", "An unknown error occurred within Indexed Database.", 0 },
71 { "ConstraintError", "A mutation operation in the transaction failed because a constraint was not satisfied.", 0 }, 66 { "ConstraintError", "A mutation operation in the transaction failed because a constraint was not satisfied.", 0 },
72 { "DataError", "The data provided does not meet requirements.", 0 }, 67 { "DataError", "The data provided does not meet requirements.", 0 },
73 { "TransactionInactiveError", "A request was placed against a transaction wh ich is either currently not active, or which is finished.", 0 }, 68 { "TransactionInactiveError", "A request was placed against a transaction wh ich is either currently not active, or which is finished.", 0 },
74 { "ReadOnlyError", "A write operation was attempted in a read-only transacti on.", 0 }, 69 { "ReadOnlyError", "A write operation was attempted in a read-only transacti on.", 0 },
75 { "VersionError", "An attempt was made to open a database using a lower vers ion than the existing version.", 0 }, 70 { "VersionError", "An attempt was made to open a database using a lower vers ion than the existing version.", 0 },
76 71
77 // File system 72 // File system
78 { "NotFoundError", "A requested file or directory could not be found at the time an operation was processed.", 8 }, 73 { "NotFoundError", "A requested file or directory could not be found at the time an operation was processed.", 8 },
79 { "SecurityError", "It was determined that certain files are unsafe for acce ss within a Web application, or that too many calls are being made on file resou rces.", 18 }, 74 { "SecurityError", "It was determined that certain files are unsafe for acce ss within a Web application, or that too many calls are being made on file resou rces.", 18 },
(...skipping 20 matching lines...) Expand all
100 }; 95 };
101 96
102 static const CoreException* getErrorEntry(ExceptionCode ec) 97 static const CoreException* getErrorEntry(ExceptionCode ec)
103 { 98 {
104 size_t tableSize = WTF_ARRAY_LENGTH(coreExceptions); 99 size_t tableSize = WTF_ARRAY_LENGTH(coreExceptions);
105 size_t tableIndex = ec - INDEX_SIZE_ERR; 100 size_t tableIndex = ec - INDEX_SIZE_ERR;
106 101
107 return tableIndex < tableSize ? &coreExceptions[tableIndex] : 0; 102 return tableIndex < tableSize ? &coreExceptions[tableIndex] : 0;
108 } 103 }
109 104
110 DOMException::DOMException(ExceptionCode ec) 105 DOMException::DOMException(unsigned short code, const char* name, const char * m essage)
106 {
107 ASSERT(name);
108 m_code = code;
109 m_name = name;
110 m_message = message;
111 ScriptWrappable::init(this);
112 }
113
114 PassRefPtr<DOMException> DOMException::create(ExceptionCode ec, const char* mess age)
111 { 115 {
112 const CoreException* entry = getErrorEntry(ec); 116 const CoreException* entry = getErrorEntry(ec);
113 ASSERT(entry); 117 ASSERT(entry);
114 if (!entry) { 118 return adoptRef(new DOMException(entry->code, entry->name ? entry->name : "E rror", message ? message : entry->message));
115 m_code = 0;
116 m_name = "UnknownError";
117 m_message = "Unknown Error";
118 } else {
119 m_code = entry->code;
120 if (entry->name)
121 m_name = entry->name;
122 else
123 m_name = "Error";
124 m_message = entry->message;
125 }
126
127 ScriptWrappable::init(this);
128 }
129
130 PassRefPtr<DOMException> DOMException::create(ExceptionCode ec)
131 {
132 return adoptRef(new DOMException(ec));
133 } 119 }
134 120
135 String DOMException::toString() const 121 String DOMException::toString() const
136 { 122 {
137 return name() + ": " + message(); 123 return name() + ": " + message();
138 } 124 }
139 125
140 String DOMException::getErrorName(ExceptionCode ec) 126 String DOMException::getErrorName(ExceptionCode ec)
141 { 127 {
142 const CoreException* entry = getErrorEntry(ec); 128 const CoreException* entry = getErrorEntry(ec);
(...skipping 16 matching lines...) Expand all
159 145
160 unsigned short DOMException::getLegacyErrorCode(ExceptionCode ec) 146 unsigned short DOMException::getLegacyErrorCode(ExceptionCode ec)
161 { 147 {
162 const CoreException* entry = getErrorEntry(ec); 148 const CoreException* entry = getErrorEntry(ec);
163 ASSERT(entry); 149 ASSERT(entry);
164 150
165 return (entry && entry->code) ? entry->code : 0; 151 return (entry && entry->code) ? entry->code : 0;
166 } 152 }
167 153
168 } // namespace WebCore 154 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698