mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-05 06:32:26 +02:00
LibWeb: Mark most stream callbacks as infallible
There are a number of script-provided stream callbacks for various
stream operations, such as `start`, `pull`, `cancel`, etc. Out of all of
these, only the `start` callback can actually throw. And when it does,
the exception is realized immediately in the corresponding stream
constructor.
All other callbacks have spec text of the form:
Throwing an exception is treated the same as returning a rejected
promise.
And indeed this is internally handled by the streams spec. Thus all of
those callbacks can be specified as returning only a promise, rather
than a WebIDL::ExceptionOr<Promise>.
This commit is contained in:
committed by
Andreas Kling
parent
ffb48ccd81
commit
bbe6b84bd6
@@ -62,9 +62,9 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<TransformStream>> TransformStream::construc
|
||||
TRY(set_up_transform_stream_default_controller_from_transformer(*stream, transformer, transformer_dict));
|
||||
|
||||
// 12. If transformerDict["start"] exists, then resolve startPromise with the result of invoking
|
||||
// transformerDict["start"] with argument list « this.[[controller]] » and callback this value transformer.
|
||||
// transformerDict["start"] with argument list « this.[[controller]] » and callback this value transformer.
|
||||
if (transformer_dict.start) {
|
||||
auto result = MUST_OR_THROW_OOM(WebIDL::invoke_callback(*transformer_dict.start, transformer, stream->controller())).release_value();
|
||||
auto result = TRY(WebIDL::invoke_callback(*transformer_dict.start, transformer, stream->controller())).release_value();
|
||||
WebIDL::resolve_promise(realm, start_promise, result);
|
||||
}
|
||||
// 13. Otherwise, resolve startPromise with undefined.
|
||||
|
||||
Reference in New Issue
Block a user