| 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 - IndexSizeError; | 100 size_t tableIndex = ec - IndexSizeError; |
| 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 Loading... |
| 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 |
| OLD | NEW |