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()); |