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

Unified Diff: Source/modules/crypto/Crypto.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/custom/V8CryptoCustom.cpp ('k') | Source/wtf/ArrayBufferView.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/crypto/Crypto.cpp
diff --git a/Source/modules/crypto/Crypto.cpp b/Source/modules/crypto/Crypto.cpp
index 1ad5b2f2106a031c92d08ed0484f69216e4a9e96..4a8a7f7e2bd30c9fb9727e275806a014c6a25fd1 100644
--- a/Source/modules/crypto/Crypto.cpp
+++ b/Source/modules/crypto/Crypto.cpp
@@ -61,12 +61,16 @@ Crypto::Crypto()
// Note: This implementation must be thread-safe, as it is used by workers.
void Crypto::getRandomValues(ArrayBufferView* array, ExceptionState& exceptionState)
{
- if (!array || !isIntegerArray(array)) {
- exceptionState.throwUninformativeAndGenericDOMException(TypeMismatchError);
+ if (!array) {
+ exceptionState.throwDOMException(TypeMismatchError, "The provided ArrayBufferView is null.");
+ return;
+ }
+ if (!isIntegerArray(array)) {
+ exceptionState.throwDOMException(TypeMismatchError, String::format("The provided ArrayBufferView is of type '%s', which is not an integer array type.", array->typeName()));
return;
}
if (array->byteLength() > 65536) {
- exceptionState.throwUninformativeAndGenericDOMException(QuotaExceededError);
+ exceptionState.throwDOMException(QuotaExceededError, String::format("The ArrayBufferView's byte length (%u) exceeds the number of bytes of entropy available via this API (65536).", array->byteLength()));
return;
}
cryptographicallyRandomValues(array->baseAddress(), array->byteLength());
« no previous file with comments | « Source/bindings/v8/custom/V8CryptoCustom.cpp ('k') | Source/wtf/ArrayBufferView.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698