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

Unified Diff: Source/modules/indexeddb/IDBDatabase.cpp

Issue 18580013: IndexedDB: Make DOMException messages more useful. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Message => ErrorMessage 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 side-by-side diff with in-line comments
Download patch
Index: Source/modules/indexeddb/IDBDatabase.cpp
diff --git a/Source/modules/indexeddb/IDBDatabase.cpp b/Source/modules/indexeddb/IDBDatabase.cpp
index 186bf64ba4e5b84aed26c334b82f17a9b06f43aa..2519801cb3d2d3ca6bd72df328fb3eff19c7076d 100644
--- a/Source/modules/indexeddb/IDBDatabase.cpp
+++ b/Source/modules/indexeddb/IDBDatabase.cpp
@@ -48,7 +48,18 @@
namespace WebCore {
-const char IDBDatabase::notFoundErrorMessage[] = "An operation failed because the requested database object could not be found.";
+const char IDBDatabase::indexDeletedErrorMessage[] = "The index or its object store has been deleted.";
+const char IDBDatabase::isKeyCursorErrorMessage[] = "The cursor is a key cursor.";
+const char IDBDatabase::noKeyOrKeyRangeErrorMessage[] = "No key or key range specified.";
+const char IDBDatabase::noSuchIndexErrorMessage[] = "The specified index was not be found.";
+const char IDBDatabase::noSuchObjectStoreErrorMessage[] = "The specified object store was not found.";
+const char IDBDatabase::notGotValueErrorMessage[] = "The cursor is being iterated or has iterated past its end.";
+const char IDBDatabase::notValidKeyErrorMessage[] = "The parameter is not a valid key.";
+const char IDBDatabase::notVersionChangeTransactionErrorMessage[] = "The database is not running a version change transaction.";
+const char IDBDatabase::objectStoreDeletedErrorMessage[] = "The object store has been deleted.";
+const char IDBDatabase::requestNotFinishedErrorMessage[] = "The request has not finished.";
+const char IDBDatabase::sourceDeletedErrorMessage[] = "The cursor's source or effective object store has been deleted.";
+const char IDBDatabase::transactionFinishedErrorMessage[] = "The transaction has finished.";
PassRefPtr<IDBDatabase> IDBDatabase::create(ScriptExecutionContext* context, PassRefPtr<IDBDatabaseBackendInterface> database, PassRefPtr<IDBDatabaseCallbacks> callbacks)
{
@@ -176,7 +187,11 @@ PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, co
IDB_TRACE("IDBDatabase::createObjectStore");
HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls", IDBCreateObjectStoreCall, IDBMethodsMax);
if (!m_versionChangeTransaction) {
- es.throwDOMException(InvalidStateError);
+ es.throwDOMException(InvalidStateError, IDBDatabase::notVersionChangeTransactionErrorMessage);
+ return 0;
+ }
+ if (m_versionChangeTransaction->isFinished()) {
+ es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage);
return 0;
}
if (!m_versionChangeTransaction->isActive()) {
@@ -185,17 +200,17 @@ PassRefPtr<IDBObjectStore> IDBDatabase::createObjectStore(const String& name, co
}
if (containsObjectStore(name)) {
- es.throwDOMException(ConstraintError);
+ es.throwDOMException(ConstraintError, "An object store with the specified name already exists.");
return 0;
}
if (!keyPath.isNull() && !keyPath.isValid()) {
- es.throwDOMException(SyntaxError);
+ es.throwDOMException(SyntaxError, "The keyPath option is not a valid key path.");
dgrogan 2013/07/12 17:58:17 What do you think of splitting this up and includi
arv (Not doing code reviews) 2013/07/12 18:07:29 One step at a time. You can use String.format or w
jsbell 2013/07/12 18:22:19 Yeah, we could go further and include the details
return 0;
}
if (autoIncrement && ((keyPath.type() == IDBKeyPath::StringType && keyPath.string().isEmpty()) || keyPath.type() == IDBKeyPath::ArrayType)) {
- es.throwDOMException(InvalidAccessError);
+ es.throwDOMException(InvalidAccessError, "The autoIncrement option was set but the keyPath option was not a non-empty string.");
return 0;
}
@@ -216,7 +231,11 @@ void IDBDatabase::deleteObjectStore(const String& name, ExceptionState& es)
IDB_TRACE("IDBDatabase::deleteObjectStore");
HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls", IDBDeleteObjectStoreCall, IDBMethodsMax);
if (!m_versionChangeTransaction) {
- es.throwDOMException(InvalidStateError);
+ es.throwDOMException(InvalidStateError, IDBDatabase::notVersionChangeTransactionErrorMessage);
+ return;
+ }
+ if (m_versionChangeTransaction->isFinished()) {
+ es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage);
return;
}
if (!m_versionChangeTransaction->isActive()) {
@@ -226,7 +245,7 @@ void IDBDatabase::deleteObjectStore(const String& name, ExceptionState& es)
int64_t objectStoreId = findObjectStoreId(name);
if (objectStoreId == IDBObjectStoreMetadata::InvalidId) {
- es.throwDOMException(NotFoundError, IDBDatabase::notFoundErrorMessage);
+ es.throwDOMException(NotFoundError, "The specified object store was not found.");
return;
}
@@ -240,7 +259,7 @@ PassRefPtr<IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* cont
IDB_TRACE("IDBDatabase::transaction");
HistogramSupport::histogramEnumeration("WebCore.IndexedDB.FrontEndAPICalls", IDBTransactionCall, IDBMethodsMax);
if (!scope.size()) {
- es.throwDOMException(InvalidAccessError);
+ es.throwDOMException(InvalidAccessError, "The storeNames parameter was empty.");
return 0;
}
@@ -248,8 +267,13 @@ PassRefPtr<IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* cont
if (es.hadException())
return 0;
- if (m_versionChangeTransaction || m_closePending) {
- es.throwDOMException(InvalidStateError);
+ if (m_versionChangeTransaction) {
+ es.throwDOMException(InvalidStateError, "A version change transaction is running.");
+ return 0;
+ }
+
+ if (m_closePending) {
+ es.throwDOMException(InvalidStateError, "The database connection is closing.");
return 0;
}
@@ -257,7 +281,7 @@ PassRefPtr<IDBTransaction> IDBDatabase::transaction(ScriptExecutionContext* cont
for (size_t i = 0; i < scope.size(); ++i) {
int64_t objectStoreId = findObjectStoreId(scope[i]);
if (objectStoreId == IDBObjectStoreMetadata::InvalidId) {
- es.throwDOMException(NotFoundError, IDBDatabase::notFoundErrorMessage);
+ es.throwDOMException(NotFoundError, "One of the specified object stores was not found.");
return 0;
}
objectStoreIds.append(objectStoreId);

Powered by Google App Engine
This is Rietveld 408576698