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

Unified Diff: Source/modules/webaudio/AudioBuffer.cpp

Issue 24877002: Add more informative messages for DOM exceptions. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Upload again Created 7 years, 3 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 | « Source/modules/webaudio/AudioBuffer.h ('k') | Source/modules/webaudio/AudioContext.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webaudio/AudioBuffer.cpp
diff --git a/Source/modules/webaudio/AudioBuffer.cpp b/Source/modules/webaudio/AudioBuffer.cpp
index e41ba22063db137dd7ad7ee09439bec5b09c7465..898b86717471751ea74d01d035e85f02f7185cc7 100644
--- a/Source/modules/webaudio/AudioBuffer.cpp
+++ b/Source/modules/webaudio/AudioBuffer.cpp
@@ -32,6 +32,7 @@
#include "modules/webaudio/AudioBuffer.h"
+#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ExceptionState.h"
#include "core/dom/ExceptionCode.h"
#include "core/platform/audio/AudioBus.h"
@@ -40,9 +41,19 @@
namespace WebCore {
+float AudioBuffer::minAllowedSampleRate()
+{
+ return 22050;
+}
+
+float AudioBuffer::maxAllowedSampleRate()
+{
+ return 96000;
+}
+
PassRefPtr<AudioBuffer> AudioBuffer::create(unsigned numberOfChannels, size_t numberOfFrames, float sampleRate)
{
- if (sampleRate < 22050 || sampleRate > 96000 || numberOfChannels > AudioContext::maxNumberOfChannels() || !numberOfFrames)
+ if (sampleRate < minAllowedSampleRate() || sampleRate > maxAllowedSampleRate() || numberOfChannels > AudioContext::maxNumberOfChannels() || !numberOfFrames)
return 0;
return adoptRef(new AudioBuffer(numberOfChannels, numberOfFrames, sampleRate));
@@ -97,7 +108,12 @@ void AudioBuffer::releaseMemory()
PassRefPtr<Float32Array> AudioBuffer::getChannelData(unsigned channelIndex, ExceptionState& es)
{
if (channelIndex >= m_channels.size()) {
- es.throwUninformativeAndGenericDOMException(SyntaxError);
+ es.throwDOMException(
+ SyntaxError,
+ ExceptionMessages::failedToExecute(
+ "getChannelData",
+ "AudioBuffer",
+ "channel index (" + String::number(channelIndex) + ") exceeds number of channels (" + String::number(m_channels.size()) + ")"));
return 0;
}
« no previous file with comments | « Source/modules/webaudio/AudioBuffer.h ('k') | Source/modules/webaudio/AudioContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698