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

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: Disambiguate TransactionInactiveError 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') | Source/modules/indexeddb/IDBDatabase.cpp » ('J')
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..5b0d3c0f53ecaa09434d1dc34bfae2de407de819 100644
--- a/Source/modules/indexeddb/IDBCursor.cpp
+++ b/Source/modules/indexeddb/IDBCursor.cpp
@@ -126,8 +126,20 @@ 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::notGotValueMessage);
arv (Not doing code reviews) 2013/07/12 17:43:08 maybe didntGetValueErrorMessage or noValueErrorMes
jsbell 2013/07/12 17:53:14 Yeah, that was contorted. I went with "noValueErro
+ return 0;
+ }
+ if (isKeyCursor()) {
+ es.throwDOMException(InvalidStateError, IDBDatabase::isKeyCursorMessage);
arv (Not doing code reviews) 2013/07/12 17:43:08 Can we name these *ErrorMessage?
jsbell 2013/07/12 17:53:14 Done (while you were typing this, actually!)
+ return 0;
+ }
+ if (isDeleted()) {
+ es.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedMessage);
+ return 0;
+ }
+ if (m_transaction->isFinished()) {
+ es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedMessage);
return 0;
}
if (!m_transaction->isActive()) {
@@ -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,11 +168,19 @@ 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::notGotValueMessage);
+ return;
+ }
+ if (isDeleted()) {
+ es.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedMessage);
return;
}
+ if (m_transaction->isFinished()) {
+ es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedMessage);
+ return;
+ }
if (!m_transaction->isActive()) {
es.throwDOMException(TransactionInactiveError);
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::notValidKeyMessage);
return;
}
+ if (m_transaction->isFinished()) {
+ es.throwDOMException(TransactionInactiveError, IDBDatabase::transactionFinishedMessage);
+ return;
+ }
if (!m_transaction->isActive()) {
es.throwDOMException(TransactionInactiveError);
return;
}
- if (!m_gotValue || isDeleted()) {
- es.throwDOMException(InvalidStateError);
+ if (!m_gotValue) {
+ es.throwDOMException(InvalidStateError, IDBDatabase::notGotValueMessage);
+ return;
+ }
+
+ if (isDeleted()) {
+ es.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedMessage);
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,6 +255,10 @@ 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::transactionFinishedMessage);
+ return 0;
+ }
if (!m_transaction->isActive()) {
es.throwDOMException(TransactionInactiveError);
return 0;
@@ -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::notGotValueMessage);
+ return 0;
+ }
+ if (isKeyCursor()) {
+ es.throwDOMException(InvalidStateError, IDBDatabase::isKeyCursorMessage);
+ return 0;
+ }
+ if (isDeleted()) {
+ es.throwDOMException(InvalidStateError, IDBDatabase::sourceDeletedMessage);
return 0;
}
« no previous file with comments | « no previous file | Source/modules/indexeddb/IDBDatabase.h » ('j') | Source/modules/indexeddb/IDBDatabase.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698