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

Unified Diff: Source/modules/webaudio/OfflineAudioContext.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/DelayNode.cpp ('k') | Source/modules/webaudio/WaveShaperNode.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/webaudio/OfflineAudioContext.cpp
diff --git a/Source/modules/webaudio/OfflineAudioContext.cpp b/Source/modules/webaudio/OfflineAudioContext.cpp
index adfe8ce72288dd06ca08f25b8b6bf35b3e839813..7cc900a6a101c7e03700ad0d0fb4c528816e2d93 100644
--- a/Source/modules/webaudio/OfflineAudioContext.cpp
+++ b/Source/modules/webaudio/OfflineAudioContext.cpp
@@ -28,6 +28,7 @@
#include "modules/webaudio/OfflineAudioContext.h"
+#include "bindings/v8/ExceptionMessages.h"
#include "bindings/v8/ExceptionState.h"
#include "core/dom/Document.h"
#include "core/dom/ExceptionCode.h"
@@ -39,14 +40,29 @@ PassRefPtr<OfflineAudioContext> OfflineAudioContext::create(ScriptExecutionConte
{
// FIXME: add support for workers.
if (!context || !context->isDocument()) {
- es.throwUninformativeAndGenericDOMException(NotSupportedError);
+ es.throwDOMException(
+ NotSupportedError,
+ ExceptionMessages::failedToConstruct("OfflineAudioContext"));
return 0;
}
Document* document = toDocument(context);
- if (numberOfChannels > 10 || !isSampleRateRangeGood(sampleRate)) {
- es.throwUninformativeAndGenericDOMException(SyntaxError);
+ if (numberOfChannels > 10) {
+ es.throwDOMException(
+ SyntaxError,
+ ExceptionMessages::failedToConstruct(
+ "OfflineAudioContext",
+ "number of channels (" + String::number(numberOfChannels) + ") exceeds maximum (10)."));
+ return 0;
+ }
+
+ if (!isSampleRateRangeGood(sampleRate)) {
+ es.throwDOMException(
+ SyntaxError,
+ ExceptionMessages::failedToConstruct(
+ "OfflineAudioContext",
+ "sample rate (" + String::number(sampleRate) + ") must be in the range 44100-96000 Hz."));
return 0;
}
« no previous file with comments | « Source/modules/webaudio/DelayNode.cpp ('k') | Source/modules/webaudio/WaveShaperNode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698