Index: Source/modules/webaudio/AudioContext.cpp |
diff --git a/Source/modules/webaudio/AudioContext.cpp b/Source/modules/webaudio/AudioContext.cpp |
index e0c7792062c7f1edc01bed3342e2272e1f0e2b44..eefed5e05024316602a327524cb97a9aa7a011eb 100644 |
--- a/Source/modules/webaudio/AudioContext.cpp |
+++ b/Source/modules/webaudio/AudioContext.cpp |
@@ -28,6 +28,7 @@ |
#include "modules/webaudio/AudioContext.h" |
+#include "bindings/v8/ExceptionMessages.h" |
#include "bindings/v8/ExceptionState.h" |
#include "core/dom/Document.h" |
#include "core/dom/ExceptionCode.h" |
@@ -293,7 +294,11 @@ PassRefPtr<AudioBuffer> AudioContext::createBuffer(unsigned numberOfChannels, si |
{ |
RefPtr<AudioBuffer> audioBuffer = AudioBuffer::create(numberOfChannels, numberOfFrames, sampleRate); |
if (!audioBuffer.get()) { |
- es.throwUninformativeAndGenericDOMException(SyntaxError); |
+ es.throwDOMException( |
+ SyntaxError, |
+ ExceptionMessages::failedToConstruct( |
+ "AudioBuffer", |
+ "invalid number of channels, frames, or sample rate.")); |
Mike West
2013/09/27 06:44:39
For these kinds of errors, it would be nice to tel
Raymond Toy (Google)
2013/09/27 16:24:10
Agreed. I'll try to make this (and all others) mor
|
return 0; |
} |
@@ -304,13 +309,21 @@ PassRefPtr<AudioBuffer> AudioContext::createBuffer(ArrayBuffer* arrayBuffer, boo |
{ |
ASSERT(arrayBuffer); |
if (!arrayBuffer) { |
- es.throwUninformativeAndGenericDOMException(SyntaxError); |
+ es.throwDOMException( |
+ SyntaxError, |
+ ExceptionMessages::failedToConstruct( |
+ "AudioBuffer", |
+ "invalid ArrayBuffer.")); |
return 0; |
} |
RefPtr<AudioBuffer> audioBuffer = AudioBuffer::createFromAudioFileData(arrayBuffer->data(), arrayBuffer->byteLength(), mixToMono, sampleRate()); |
if (!audioBuffer.get()) { |
- es.throwUninformativeAndGenericDOMException(SyntaxError); |
+ es.throwDOMException( |
+ SyntaxError, |
+ ExceptionMessages::failedToConstruct( |
+ "AudioBuffer", |
+ "invalid audio data in ArrayBuffer.")); |
return 0; |
} |
@@ -320,7 +333,12 @@ PassRefPtr<AudioBuffer> AudioContext::createBuffer(ArrayBuffer* arrayBuffer, boo |
void AudioContext::decodeAudioData(ArrayBuffer* audioData, PassRefPtr<AudioBufferCallback> successCallback, PassRefPtr<AudioBufferCallback> errorCallback, ExceptionState& es) |
{ |
if (!audioData) { |
- es.throwUninformativeAndGenericDOMException(SyntaxError); |
+ es.throwDOMException( |
+ SyntaxError, |
+ ExceptionMessages::failedToExecute( |
+ "decodeAudioData", |
+ "AudioContext", |
+ "invalid ArrayBuffer for audioData.")); |
return; |
} |
m_audioDecoder.decodeAsync(audioData, sampleRate(), successCallback, errorCallback); |
@@ -341,9 +359,12 @@ PassRefPtr<AudioBufferSourceNode> AudioContext::createBufferSource() |
PassRefPtr<MediaElementAudioSourceNode> AudioContext::createMediaElementSource(HTMLMediaElement* mediaElement, ExceptionState& es) |
{ |
- ASSERT(mediaElement); |
Mike West
2013/09/27 06:44:39
Why drop the ASSERT?
Raymond Toy (Google)
2013/09/27 16:24:10
When running the webaudio layout tests in debug mo
|
if (!mediaElement) { |
- es.throwUninformativeAndGenericDOMException(InvalidStateError); |
+ es.throwDOMException( |
+ InvalidStateError, |
+ ExceptionMessages::failedToConstruct( |
+ "MediaElementAudioSourceNode", |
+ "invalid HTMLMedialElement.")); |
return 0; |
} |
@@ -352,7 +373,11 @@ PassRefPtr<MediaElementAudioSourceNode> AudioContext::createMediaElementSource(H |
// First check if this media element already has a source node. |
if (mediaElement->audioSourceNode()) { |
- es.throwUninformativeAndGenericDOMException(InvalidStateError); |
+ es.throwDOMException( |
+ InvalidStateError, |
+ ExceptionMessages::failedToConstruct( |
+ "MediaElementAudioSourceNode", |
+ "invalid HTMLMediaElement.")); |
return 0; |
} |
@@ -366,9 +391,10 @@ PassRefPtr<MediaElementAudioSourceNode> AudioContext::createMediaElementSource(H |
PassRefPtr<MediaStreamAudioSourceNode> AudioContext::createMediaStreamSource(MediaStream* mediaStream, ExceptionState& es) |
{ |
- ASSERT(mediaStream); |
if (!mediaStream) { |
- es.throwUninformativeAndGenericDOMException(InvalidStateError); |
+ es.throwDOMException( |
+ InvalidStateError, |
+ ExceptionMessages::failedToConstruct("MediaStreamAudioSourceNode")); |
Mike West
2013/09/27 06:44:39
"invalid MediaStream source"?
|
return 0; |
} |
@@ -423,7 +449,11 @@ PassRefPtr<ScriptProcessorNode> AudioContext::createScriptProcessor(size_t buffe |
RefPtr<ScriptProcessorNode> node = ScriptProcessorNode::create(this, m_destinationNode->sampleRate(), bufferSize, numberOfInputChannels, numberOfOutputChannels); |
if (!node.get()) { |
- es.throwUninformativeAndGenericDOMException(SyntaxError); |
+ es.throwDOMException( |
+ SyntaxError, |
+ ExceptionMessages::failedToConstruct( |
+ "ScriptProcessorNode", |
+ "invalid buffer size, or number of input/outputs.")); |
return 0; |
} |
@@ -510,7 +540,11 @@ PassRefPtr<ChannelSplitterNode> AudioContext::createChannelSplitter(size_t numbe |
RefPtr<ChannelSplitterNode> node = ChannelSplitterNode::create(this, m_destinationNode->sampleRate(), numberOfOutputs); |
if (!node.get()) { |
- es.throwUninformativeAndGenericDOMException(SyntaxError); |
+ es.throwDOMException( |
+ SyntaxError, |
+ ExceptionMessages::failedToConstruct( |
+ "ChannelSplitterNode", |
+ "invalid number of outputs.")); |
Mike West
2013/09/27 06:44:39
"The number of outputs (" + String::number(numberO
|
return 0; |
} |
@@ -531,7 +565,11 @@ PassRefPtr<ChannelMergerNode> AudioContext::createChannelMerger(size_t numberOfI |
RefPtr<ChannelMergerNode> node = ChannelMergerNode::create(this, m_destinationNode->sampleRate(), numberOfInputs); |
if (!node.get()) { |
- es.throwUninformativeAndGenericDOMException(SyntaxError); |
+ es.throwDOMException( |
+ SyntaxError, |
+ ExceptionMessages::failedToConstruct( |
+ "ChannelMergerNode", |
+ "invalid number of inputs.")); |
Mike West
2013/09/27 06:44:39
Same as for outputs.
|
return 0; |
} |
@@ -557,7 +595,11 @@ PassRefPtr<PeriodicWave> AudioContext::createPeriodicWave(Float32Array* real, Fl |
ASSERT(isMainThread()); |
if (!real || !imag || (real->length() != imag->length())) { |
- es.throwUninformativeAndGenericDOMException(SyntaxError); |
+ es.throwDOMException( |
+ SyntaxError, |
+ ExceptionMessages::failedToConstruct( |
+ "WaveTable", |
+ "invalid real or imag arrays for wave table.")); |
Mike West
2013/09/27 06:44:39
One option would be to split this up into multiple
|
return 0; |
} |