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

Unified Diff: Source/bindings/v8/ExceptionState.cpp

Issue 87963002: Improve Crypto::getRandomValues exception messages. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: DEBUG. Created 7 years, 1 month 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 | « Source/bindings/v8/ExceptionState.h ('k') | Source/bindings/v8/custom/V8CryptoCustom.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/ExceptionState.cpp
diff --git a/Source/bindings/v8/ExceptionState.cpp b/Source/bindings/v8/ExceptionState.cpp
index 6d666b35f3ee4acaf5cc48f0361ed36ac0c9814e..16f0c45b3a34dfbc0f6014b42b8dc260c1e7d1d1 100644
--- a/Source/bindings/v8/ExceptionState.cpp
+++ b/Source/bindings/v8/ExceptionState.cpp
@@ -31,6 +31,7 @@
#include "config.h"
#include "bindings/v8/ExceptionState.h"
+#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/V8ThrowException.h"
#include "core/dom/ExceptionCode.h"
@@ -50,8 +51,22 @@ void ExceptionState::throwDOMException(const ExceptionCode& ec, const String& me
// SecurityError is thrown via ::throwSecurityError, and _careful_ consideration must be given to the data exposed to JavaScript via the 'sanitizedMessage'.
ASSERT(ec != SecurityError);
+ String processedMessage = message;
+ if (propertyName() && interfaceName() && m_context != UnknownContext) {
+ if (m_context == DeletionContext)
+ processedMessage = ExceptionMessages::failedToDelete(propertyName(), interfaceName(), message);
+ else if (m_context == ExecutionContext)
+ processedMessage = ExceptionMessages::failedToExecute(propertyName(), interfaceName(), message);
+ else if (m_context == GetterContext)
+ processedMessage = ExceptionMessages::failedToGet(propertyName(), interfaceName(), message);
+ else if (m_context == SetterContext)
+ processedMessage = ExceptionMessages::failedToSet(propertyName(), interfaceName(), message);
+ } else if (!propertyName() && interfaceName() && m_context == ConstructionContext) {
+ processedMessage = ExceptionMessages::failedToConstruct(interfaceName(), message);
+ }
+
m_code = ec;
- setException(V8ThrowException::createDOMException(ec, message, m_creationContext, m_isolate));
+ setException(V8ThrowException::createDOMException(ec, processedMessage, m_creationContext, m_isolate));
}
void ExceptionState::throwSecurityError(const String& sanitizedMessage, const String& unsanitizedMessage)
« no previous file with comments | « Source/bindings/v8/ExceptionState.h ('k') | Source/bindings/v8/custom/V8CryptoCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698