diff --git a/index.bs b/index.bs
index 7941a24a0..d238f6f1e 100644
--- a/index.bs
+++ b/index.bs
@@ -1035,11 +1035,6 @@ Instances of WritableStream
are created with the internal slots des
"closed"
; returned by the
closed
getter
- "errored"
state
- WritableStream
are created with the internal slots des
1. Set *this*@[[queue]] to a new empty List.
1. Set *this*@[[state]] to "writable".
1. Set *this*@[[started]] and *this*@[[writing]] to *false*.
- 1. Set *this*@[[error]] to CreateWritableStreamErrorFunction(*this*).
1. Call-with-rethrow SyncWritableStreamStateWithQueue(*this*).
- 1. Let _startResult_ be InvokeOrNoop(_underlyingSink_, "start", «*this*@[[error]]»).
+ 1. Let _error_ be a new WritableStream
error function.
+ 1. Set _error_@[[stream]] to *this*.
+ 1. Let _startResult_ be InvokeOrNoop(_underlyingSink_, "start", «_error_»).
1. ReturnIfAbrupt(_startResult_).
1. Set *this*@[[startedPromise]] to the result of resolving _startResult_ as a promise.
1. Upon fulfillment,
1. Set *this*@[[started]] to *true*.
1. Set *this*@[[startedPromise]] to *undefined*.
- 1. Upon rejection with reason _r_, call-with-rethrow Call(*this*@[[error]], *undefined*, «_r_»).
+ 1. Upon rejection with reason _r_, return ErrorWritableStream(*this*, _r_).
+
+
+A WritableStream
error function is an anonymous built-in function that is used to allow
+underlying sinks to error their associated writable stream. Each WritableStream
error function has
+a \[[stream]] internal slot. When a WritableStream
error function F is called with argument
+e, it performs the following steps:
+
++ 1. Let _stream_ be _F_@[[stream]]. + 1. Return ErrorWritableStream(_stream_, _e_).
WritableStream
PrototypeWritableStream
are created with the internal slots des
1. If IsWritableStream(*this*) is *false*, return a promise rejected with a *TypeError* exception.
1. If *this*@[[state]] is "closed", return a new promise resolved with *undefined*.
1. If *this*@[[state]] is "errored", return a new promise rejected with *this*@[[storedError]].
- 1. Call-with-rethrow Call(*this*@[[error]], *undefined*, «reason»).
+ 1. Call-with-rethrow ErrorWritableStream(*this*, _reason_).
1. Let _sinkAbortPromise_ be PromiseInvokeOrFallbackOrNoop(*this*@[[underlyingSink]], "abort", «_reason_», "close", «»).
1. Return the result of transforming _sinkAbortPromise_ by a fulfillment handler that returns *undefined*.
@@ -1257,24 +1263,24 @@ Instances of WritableStream
are created with the internal slots des
1. Let _chunkSize_ be *1*.
1. Let _strategy_ be Get(*this*@[[underlyingSink]], "strategy").
1. If _strategy_ is an abrupt completion,
- 1. Call-with-rethrow Call(*this*@[[error]], *undefined*, «_strategy_.[[value]]»).
+ 1. Call-with-rethrow ErrorWritableStream(*this*, _strategy_.[[value]]).
1. Return a new promise rejected with _strategy_.[[value]].
1. Set _strategy_ to _strategy_.[[value]].
1. If _strategy_ is not *undefined*, then
1. Set _chunkSize_ to Invoke(_strategy_, "size", «_chunk_»).
1. If _chunkSize_ is an abrupt completion,
- 1. Call-with-rethrow Call(*this*@[[error]], *undefined*, «_chunkSize_.[[value]]»).
+ 1. Call-with-rethrow ErrorWritableStream(*this*, _chunkSize_.[[value]]).
1. Return a new promise rejected with _chunkSize_.[[value]].
1. Set _chunkSize_ to _chunkSize_.[[value]].
1. Let _promise_ be a new promise.
1. Let _writeRecord_ be Record{[[promise]]: _promise_, [[chunk]]: _chunk_}.
1. Let _enqueueResult_ be EnqueueValueWithSize(*this*@[[queue]], _writeRecord_, _chunkSize_).
1. If _enqueueResult_ is an abrupt completion,
- 1. Call-with-rethrow Call(*this*@[[error]], *undefined*, «_enqueueResult_.[[value]]»).
+ 1. Call-with-rethrow ErrorWritableStream(*this*, _enqueueResult_.[[value]]).
1. Return a new promise rejected with _enqueueResult_.[[value]].
1. Let _syncResult_ be SyncWritableStreamStateWithQueue(*this*).
1. If _syncResult_ is an abrupt completion,
- 1. Call-with-rethrow Call(*this*@[[error]], *undefined*, «_syncResult_.[[value]]»).
+ 1. Call-with-rethrow ErrorWritableStream(*this*, _syncResult_.[[value]]).
1. Return _promise_.
1. Call-with-rethrow CallOrScheduleWritableStreamAdvanceQueue(*this*).
1. Return _promise_.
@@ -1301,18 +1307,11 @@ Instances of WritableStream
are created with the internal slots des
1. Assert: _stream_@[[state]] is "closing".
1. Resolve _stream_@[[closedPromise]] with *undefined*.
1. Set _stream_@[[state]] to "closed".
- 1. Upon rejection with reason _r_, call-with-rethrow Call(_stream_@[[error]], *undefined*, «_r_»).
+ 1. Upon rejection with reason _r_, return ErrorWritableStream(_stream_, _r_).
1. Return *undefined*.
-- 1. Return a new Writable Stream Error Function closing over _stream_. -- -A Writable Stream Error Function is a built-in anonymous function of one argument e, closing over -a variable stream, that performs the following steps: +
1. If _stream_@[[state]] is "closed" or "errored", return *undefined*. @@ -1323,6 +1322,7 @@ a variable stream, that performs the following steps: 1. If _stream_@[[state]] is "waiting", resolve _stream_@[[readyPromise]] with *undefined*. 1. Reject _stream_@[[closedPromise]] with _e_. 1. Set _stream_@[[state]] to "errored". + 1. Return *undefined*.