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

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

Issue 18580013: IndexedDB: Make DOMException messages more useful. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Specific message for inactive transactions 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
« no previous file with comments | « no previous file | Source/modules/indexeddb/IDBDatabase.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/indexeddb/IDBCursor.cpp
diff --git a/Source/modules/indexeddb/IDBCursor.cpp b/Source/modules/indexeddb/IDBCursor.cpp
index a4eec9b77e80a6319f53fd698c72cce878a5c806..53978baec59f58bae9d4a7071713f98ab11586ca 100644
--- a/Source/modules/indexeddb/IDBCursor.cpp
+++ b/Source/modules/indexeddb/IDBCursor.cpp
@@ -126,12 +126,24 @@ PassRefPtr<IDBRequest> IDBCursor::update(ScriptState* state, ScriptValue& value,
{
IDB_TRACE("IDBCursor::update");
- if (!m_gotValue || isKeyCursor() || isDeleted()) {
- es.throwDOMException(InvalidStateError);
+ if (!m_gotValue) {
+ es.throwDOMException(InvalidStateError, IDBDatabase::noValueErrorMessage);
+ return 0;
+ }
+ if (isKeyCursor()) {
+ es.throwDOMException(InvalidStateError, IDBDatabase::isKeyCursorErrorMessage);
+ return 0;
+ }
+ if (isDeleted()) {
+ es.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedErrorMessage);
+ return 0;
+ }
+ if (m_transaction->isFinished()) {
+ es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage);
return 0;
}
if (!m_transaction->isActive()) {
- es.throwDOMException(TransactionInactiveError);
+ es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionInactiveErrorMessage);
return 0;
}
if (m_transaction->isReadOnly()) {
@@ -145,7 +157,7 @@ PassRefPtr<IDBRequest> IDBCursor::update(ScriptState* state, ScriptValue& value,
if (usesInLineKeys) {
RefPtr<IDBKey> keyPathKey = createIDBKeyFromScriptValueAndKeyPath(m_request->requestState(), value, keyPath);
if (!keyPathKey || !keyPathKey->isEqual(m_currentPrimaryKey.get())) {
- es.throwDOMException(DataError);
+ es.throwDOMException(DataError, "The effective object store of this cursor uses in-line keys and evaluating the key path of the value parameter results in a different value than the cursor's effective key.");
return 0;
}
}
@@ -156,13 +168,21 @@ PassRefPtr<IDBRequest> IDBCursor::update(ScriptState* state, ScriptValue& value,
void IDBCursor::advance(unsigned long count, ExceptionState& es)
{
IDB_TRACE("IDBCursor::advance");
- if (!m_gotValue || isDeleted()) {
- es.throwDOMException(InvalidStateError);
+ if (!m_gotValue) {
+ es.throwDOMException(InvalidStateError, IDBDatabase::noValueErrorMessage);
+ return;
+ }
+ if (isDeleted()) {
+ es.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedErrorMessage);
return;
}
+ if (m_transaction->isFinished()) {
+ es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage);
+ return;
+ }
if (!m_transaction->isActive()) {
- es.throwDOMException(TransactionInactiveError);
+ es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionInactiveErrorMessage);
return;
}
@@ -187,17 +207,26 @@ void IDBCursor::continueFunction(PassRefPtr<IDBKey> key, ExceptionState& es)
{
IDB_TRACE("IDBCursor::continue");
if (key && !key->isValid()) {
- es.throwDOMException(DataError);
+ es.throwDOMException(DataError, IDBDatabase::notValidKeyErrorMessage);
return;
}
+ if (m_transaction->isFinished()) {
+ es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage);
+ return;
+ }
if (!m_transaction->isActive()) {
- es.throwDOMException(TransactionInactiveError);
+ es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionInactiveErrorMessage);
return;
}
- if (!m_gotValue || isDeleted()) {
- es.throwDOMException(InvalidStateError);
+ if (!m_gotValue) {
+ es.throwDOMException(InvalidStateError, IDBDatabase::noValueErrorMessage);
+ return;
+ }
+
+ if (isDeleted()) {
+ es.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedErrorMessage);
return;
}
@@ -205,12 +234,12 @@ void IDBCursor::continueFunction(PassRefPtr<IDBKey> key, ExceptionState& es)
ASSERT(m_currentKey);
if (m_direction == IndexedDB::CursorNext || m_direction == IndexedDB::CursorNextNoDuplicate) {
if (!m_currentKey->isLessThan(key.get())) {
- es.throwDOMException(DataError);
+ es.throwDOMException(DataError, "The parameter is less than or equal to this cursor's position.");
return;
}
} else {
if (!key->isLessThan(m_currentKey.get())) {
- es.throwDOMException(DataError);
+ es.throwDOMException(DataError, "The parameter is greater than or equal to this cursor's position.");
return;
}
}
@@ -226,8 +255,12 @@ void IDBCursor::continueFunction(PassRefPtr<IDBKey> key, ExceptionState& es)
PassRefPtr<IDBRequest> IDBCursor::deleteFunction(ScriptExecutionContext* context, ExceptionState& es)
{
IDB_TRACE("IDBCursor::delete");
+ if (m_transaction->isFinished()) {
+ es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedErrorMessage);
+ return 0;
+ }
if (!m_transaction->isActive()) {
- es.throwDOMException(TransactionInactiveError);
+ es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionInactiveErrorMessage);
return 0;
}
if (m_transaction->isReadOnly()) {
@@ -235,8 +268,16 @@ PassRefPtr<IDBRequest> IDBCursor::deleteFunction(ScriptExecutionContext* context
return 0;
}
- if (!m_gotValue || isKeyCursor() || isDeleted()) {
- es.throwDOMException(InvalidStateError);
+ if (!m_gotValue) {
+ es.throwDOMException(InvalidStateError, IDBDatabase::noValueErrorMessage);
+ return 0;
+ }
+ if (isKeyCursor()) {
+ es.throwDOMException(InvalidStateError, IDBDatabase::isKeyCursorErrorMessage);
+ return 0;
+ }
+ if (isDeleted()) {
+ es.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedErrorMessage);
return 0;
}
« no previous file with comments | « no previous file | Source/modules/indexeddb/IDBDatabase.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698