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

Unified Diff: Source/bindings/v8/V8BindingMacros.h

Issue 232563003: API functions returning Promises should not throw exceptions. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 8 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
Index: Source/bindings/v8/V8BindingMacros.h
diff --git a/Source/bindings/v8/V8BindingMacros.h b/Source/bindings/v8/V8BindingMacros.h
index 95e3cbbf7a52b3b52101630bc35d3dca56dfce03..67629a58879a2806bf7a15952589415c393fd242 100644
--- a/Source/bindings/v8/V8BindingMacros.h
+++ b/Source/bindings/v8/V8BindingMacros.h
@@ -57,6 +57,19 @@ namespace WebCore {
} \
}
+#define TONATIVE_VOID_ASYNC(type, var, value, info) \
+ type var; \
+ { \
+ v8::TryCatch block; \
+ var = (value); \
+ if (UNLIKELY(block.HasCaught())) { \
+ v8::Isolate* isolate = info.GetIsolate(); \
+ ScriptPromise promise = ScriptPromise::reject(block.Exception(), isolate); \
+ v8SetReturnValue(info, promise.v8Value()); \
+ return; \
+ } \
+ }
+
#define TONATIVE_BOOL(type, var, value, retVal) \
type var; \
{ \
@@ -79,15 +92,28 @@ namespace WebCore {
return; \
}
+#define TONATIVE_VOID_EXCEPTIONSTATE_ASYNC(type, var, value, exceptionState, info) \
+ type var; \
+ { \
+ v8::TryCatch block; \
+ var = (value); \
+ if (UNLIKELY(block.HasCaught())) \
+ exceptionState.rethrowV8Exception(block.Exception()); \
+ if (UNLIKELY(exceptionState.hadException())) { \
+ v8SetReturnValue(info, exceptionState.reject().v8Value()); \
+ return; \
+ } \
+ }
+
#define TONATIVE_BOOL_EXCEPTIONSTATE(type, var, value, exceptionState, retVal) \
- type var; \
- { \
- v8::TryCatch block; \
- var = (value); \
- if (UNLIKELY(block.HasCaught())) \
- exceptionState.rethrowV8Exception(block.Exception()); \
- if (UNLIKELY(exceptionState.throwIfNeeded())) \
- return retVal; \
+ type var; \
+ { \
+ v8::TryCatch block; \
+ var = (value); \
+ if (UNLIKELY(block.HasCaught())) \
+ exceptionState.rethrowV8Exception(block.Exception()); \
+ if (UNLIKELY(exceptionState.throwIfNeeded())) \
+ return retVal; \
}
// type is an instance of class template V8StringResource<>,
@@ -103,6 +129,19 @@ namespace WebCore {
if (UNLIKELY(!var.prepare())) \
return retVal;
+#define TOSTRING_VOID_ASYNC(type, var, value, info) \
+ type var(value); \
+ { \
+ v8::TryCatch block; \
+ var.prepare(); \
+ if (UNLIKELY(block.HasCaught())) { \
+ v8::Isolate* isolate = info.GetIsolate(); \
+ ScriptPromise promise = ScriptPromise::reject(block.Exception(), isolate); \
+ v8SetReturnValue(info, promise.v8Value()); \
+ return; \
+ } \
+ }
+
} // namespace WebCore
#endif // V8BindingMacros_h

Powered by Google App Engine
This is Rietveld 408576698