Chromium Code Reviews| Index: Source/modules/webaudio/AudioNode.cpp |
| diff --git a/Source/modules/webaudio/AudioNode.cpp b/Source/modules/webaudio/AudioNode.cpp |
| index 0e66fd12f366797aac7a1b8de3ae1f9cfc7fffc1..cfa38af15b3d32dd9d2d3d6a72ee5a0b37c5979f 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", |
| + "invalid output index.")); |
|
Mike West
2013/09/27 06:44:39
"The provided output index (8) is larger than the
|
| return; |
| } |
| if (destination && inputIndex >= destination->numberOfInputs()) { |
| - es.throwUninformativeAndGenericDOMException(IndexSizeError); |
| + es.throwDOMException( |
| + IndexSizeError, |
| + ExceptionMessages::failedToExecute( |
| + "connect", |
| + "AudioNode", |
| + "invalid input index.")); |
|
Mike West
2013/09/27 06:44:39
Same as above.
|
| return; |
| } |
| if (context() != destination->context()) { |
| - es.throwUninformativeAndGenericDOMException(SyntaxError); |
| + es.throwDOMException( |
| + SyntaxError, |
| + ExceptionMessages::failedToExecute( |
| + "connect", |
| + "AudioNode", |
| + "invalid destination 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", |
| + "invalid output index.")); |
| return; |
| } |
| if (context() != param->context()) { |
| - es.throwUninformativeAndGenericDOMException(SyntaxError); |
| + es.throwDOMException( |
| + SyntaxError, |
| + ExceptionMessages::failedToExecute( |
| + "connect", |
| + "AudioNode", |
| + "destination context is different.")); |
| 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", |
| + "invalid output index.")); |
|
Mike West
2013/09/27 06:44:39
Same as above.
|
| return; |
| } |
| @@ -214,7 +255,12 @@ void AudioNode::setChannelCount(unsigned long channelCount, ExceptionState& es) |
| updateChannelsForInputs(); |
| } |
| } else { |
| - es.throwUninformativeAndGenericDOMException(InvalidStateError); |
| + es.throwDOMException( |
| + InvalidStateError, |
| + ExceptionMessages::failedToSet( |
| + "channelCount", |
| + "AudioNode", |
| + "invalid number of channels.")); |
|
Mike West
2013/09/27 06:44:39
Perhaps split this into "The channel count may not
|
| } |
| } |
| @@ -239,14 +285,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", |
| + "must be \"max\", \"clamped-max\", or \"explicit\".")); |
|
Mike West
2013/09/27 06:44:39
I'd suggest including the developer's input here:
Raymond Toy (Google)
2013/09/27 16:24:10
Agreed.
|
| + } |
| if (m_channelCountMode != oldMode) |
| updateChannelsForInputs(); |
| @@ -269,12 +321,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", |
| + "must be \"speakers\" or \"discrete\".")); |
|
Mike West
2013/09/27 06:44:39
Same as above.
|
| + } |
| } |
| void AudioNode::updateChannelsForInputs() |