Index: Source/modules/webaudio/AudioNode.cpp |
diff --git a/Source/modules/webaudio/AudioNode.cpp b/Source/modules/webaudio/AudioNode.cpp |
index 0e66fd12f366797aac7a1b8de3ae1f9cfc7fffc1..ee7576c05742d50ff282b5620170749c1b32181b 100644 |
--- a/Source/modules/webaudio/AudioNode.cpp |
+++ b/Source/modules/webaudio/AudioNode.cpp |
@@ -28,6 +28,7 @@ |
#include "modules/webaudio/AudioNode.h" |
+#include "bindings/v8/ExceptionMessages.h" |
#include "bindings/v8/ExceptionState.h" |
#include "core/dom/ExceptionCode.h" |
#include "modules/webaudio/AudioContext.h" |
@@ -130,23 +131,43 @@ void AudioNode::connect(AudioNode* destination, unsigned outputIndex, unsigned i |
AudioContext::AutoLocker locker(context()); |
if (!destination) { |
- es.throwUninformativeAndGenericDOMException(SyntaxError); |
+ es.throwDOMException( |
+ SyntaxError, |
+ ExceptionMessages::failedToExecute( |
+ "connect", |
+ "AudioNode", |
+ "invalid destination node.")); |
return; |
} |
// Sanity check input and output indices. |
if (outputIndex >= numberOfOutputs()) { |
- es.throwUninformativeAndGenericDOMException(IndexSizeError); |
+ es.throwDOMException( |
+ IndexSizeError, |
+ ExceptionMessages::failedToExecute( |
+ "connect", |
+ "AudioNode", |
+ "output index (" + String::number(outputIndex) + ") exceeds number of outputs (" + String::number(numberOfOutputs()) + ").")); |
return; |
} |
if (destination && inputIndex >= destination->numberOfInputs()) { |
- es.throwUninformativeAndGenericDOMException(IndexSizeError); |
+ es.throwDOMException( |
+ IndexSizeError, |
+ ExceptionMessages::failedToExecute( |
+ "connect", |
+ "AudioNode", |
+ "input index (" + String::number(inputIndex) + ") exceeds number of inputs (" + String::number(destination->numberOfInputs()) + ").")); |
return; |
} |
if (context() != destination->context()) { |
- es.throwUninformativeAndGenericDOMException(SyntaxError); |
+ es.throwDOMException( |
+ SyntaxError, |
+ ExceptionMessages::failedToExecute( |
+ "connect", |
+ "AudioNode", |
+ "cannot connect to a destination belonging to a different audio context.")); |
return; |
} |
@@ -164,17 +185,32 @@ void AudioNode::connect(AudioParam* param, unsigned outputIndex, ExceptionState& |
AudioContext::AutoLocker locker(context()); |
if (!param) { |
- es.throwUninformativeAndGenericDOMException(SyntaxError); |
+ es.throwDOMException( |
+ SyntaxError, |
+ ExceptionMessages::failedToExecute( |
+ "connect", |
+ "AudioNode", |
+ "invalid AudioParam.")); |
return; |
} |
if (outputIndex >= numberOfOutputs()) { |
- es.throwUninformativeAndGenericDOMException(IndexSizeError); |
+ es.throwDOMException( |
+ IndexSizeError, |
+ ExceptionMessages::failedToExecute( |
+ "connect", |
+ "AudioNode", |
+ "output index (" + String::number(outputIndex) + ") exceeds number of outputs (" + String::number(numberOfOutputs()) + ").")); |
return; |
} |
if (context() != param->context()) { |
- es.throwUninformativeAndGenericDOMException(SyntaxError); |
+ es.throwDOMException( |
+ SyntaxError, |
+ ExceptionMessages::failedToExecute( |
+ "connect", |
+ "AudioNode", |
+ "cannot connect to an AudioParam belonging to a different audio context.")); |
return; |
} |
@@ -189,7 +225,12 @@ void AudioNode::disconnect(unsigned outputIndex, ExceptionState& es) |
// Sanity check input and output indices. |
if (outputIndex >= numberOfOutputs()) { |
- es.throwUninformativeAndGenericDOMException(IndexSizeError); |
+ es.throwDOMException( |
+ IndexSizeError, |
+ ExceptionMessages::failedToExecute( |
+ "disconnect", |
+ "AudioNode", |
+ "output index (" + String::number(outputIndex) + ") exceeds number of outputs (" + String::number(numberOfOutputs()) + ").")); |
return; |
} |
@@ -214,7 +255,14 @@ void AudioNode::setChannelCount(unsigned long channelCount, ExceptionState& es) |
updateChannelsForInputs(); |
} |
} else { |
- es.throwUninformativeAndGenericDOMException(InvalidStateError); |
+ es.throwDOMException( |
+ InvalidStateError, |
+ ExceptionMessages::failedToSet( |
+ "channelCount", |
+ "AudioNode", |
+ "channel count (" + String::number(channelCount) |
+ + ") must be between 1 and " |
+ + String::number(AudioContext::maxNumberOfChannels()) + ".")); |
} |
} |
@@ -239,14 +287,20 @@ void AudioNode::setChannelCountMode(const String& mode, ExceptionState& es) |
ChannelCountMode oldMode = m_channelCountMode; |
- if (mode == "max") |
+ if (mode == "max") { |
m_channelCountMode = Max; |
- else if (mode == "clamped-max") |
+ } else if (mode == "clamped-max") { |
m_channelCountMode = ClampedMax; |
- else if (mode == "explicit") |
+ } else if (mode == "explicit") { |
m_channelCountMode = Explicit; |
- else |
- es.throwUninformativeAndGenericDOMException(InvalidStateError); |
+ } else { |
+ es.throwDOMException( |
+ InvalidStateError, |
+ ExceptionMessages::failedToSet( |
+ "channelCountMode", |
+ "AudioNode", |
+ "invalid mode '" + mode + "'; must be 'max', 'clamped-max', or 'explicit'.")); |
+ } |
if (m_channelCountMode != oldMode) |
updateChannelsForInputs(); |
@@ -269,12 +323,18 @@ void AudioNode::setChannelInterpretation(const String& interpretation, Exception |
ASSERT(isMainThread()); |
AudioContext::AutoLocker locker(context()); |
- if (interpretation == "speakers") |
+ if (interpretation == "speakers") { |
m_channelInterpretation = AudioBus::Speakers; |
- else if (interpretation == "discrete") |
+ } else if (interpretation == "discrete") { |
m_channelInterpretation = AudioBus::Discrete; |
- else |
- es.throwUninformativeAndGenericDOMException(InvalidStateError); |
+ } else { |
+ es.throwDOMException( |
+ InvalidStateError, |
+ ExceptionMessages::failedToSet( |
+ "channelInterpretation", |
+ "AudioNode", |
+ "invalid interpretation '" + interpretation + "'; must be 'speakers' or 'discrete'.")); |
+ } |
} |
void AudioNode::updateChannelsForInputs() |