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

Unified Diff: Source/bindings/templates/methods.cpp

Issue 675693002: An API returning a Promise should not throw an exceptions [overload version] (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 2 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/bindings/scripts/v8_interface.py ('k') | Source/bindings/tests/idls/core/TestInterface.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/templates/methods.cpp
diff --git a/Source/bindings/templates/methods.cpp b/Source/bindings/templates/methods.cpp
index 992485a169800240e619b30cd7354ff25e663ddc..aadc5be57086e13773b483a2fc52c331ab8b9c61 100644
--- a/Source/bindings/templates/methods.cpp
+++ b/Source/bindings/templates/methods.cpp
@@ -326,8 +326,8 @@ ExceptionMessages::failedToExecute("{{method.name}}", "{{interface_name}}", {{er
{######################################}
-{% macro throw_from_exception_state(method) %}
-{% if method.idl_type == 'Promise' %}
+{% macro throw_from_exception_state(method_or_overloads) %}
+{% if method_or_overloads.idl_type == 'Promise' or method_or_overloads.returns_promise_all %}
v8SetReturnValue(info, exceptionState.reject(ScriptState::current(info.GetIsolate())).v8Value())
{%- else %}
exceptionState.throwIfNeeded()
@@ -410,13 +410,13 @@ static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI
{% if overloads.valid_arities %}
if (info.Length() >= {{overloads.minarg}}) {
setArityTypeError(exceptionState, "{{overloads.valid_arities}}", info.Length());
- exceptionState.throwIfNeeded();
+ {{throw_from_exception_state(overloads)}};
return;
}
{% endif %}
{# Otherwise just report "not enough arguments" #}
exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments({{overloads.minarg}}, info.Length()));
- exceptionState.throwIfNeeded();
+ {{throw_from_exception_state(overloads)}};
return;
{% endif %}
}
@@ -426,7 +426,7 @@ static void {{overloads.name}}Method{{world_suffix}}(const v8::FunctionCallbackI
{% else %}
{# No match, throw error #}
exceptionState.throwTypeError("No function was found that matched the signature provided.");
- exceptionState.throwIfNeeded();
+ {{throw_from_exception_state(overloads)}};
{% endif %}
}
{% endmacro %}
« no previous file with comments | « Source/bindings/scripts/v8_interface.py ('k') | Source/bindings/tests/idls/core/TestInterface.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698