Stage 1 Draft / May 10, 2021

Error Cause

1 Placeholder to ensure correct clause numbering

2 Placeholder to ensure correct clause numbering

3 Placeholder to ensure correct clause numbering

4 Placeholder to ensure correct clause numbering

5 Placeholder to ensure correct clause numbering

6 Placeholder to ensure correct clause numbering

7 Abstract Operations

7.1 Placeholder to ensure correct clause numbering

7.2 Placeholder to ensure correct clause numbering

7.3 Operations on Objects

7.3.1 Placeholder to ensure correct clause numbering

7.3.2 Placeholder to ensure correct clause numbering

7.3.3 Placeholder to ensure correct clause numbering

7.3.4 Placeholder to ensure correct clause numbering

7.3.5 Placeholder to ensure correct clause numbering

7.3.6 CreateNonEnumerableDataPropertyOrThrow ( O, P, V )

The abstract operation CreateNonEnumerableDataPropertyOrThrow takes arguments O (an Object), P (a Property Key), and V (an ECMAScript language value). It is used to create a new non-enumerable own property of an object. It throws a TypeError exception if the requested property update cannot be performed. It performs the following steps when called:

  1. Let newDesc be the PropertyDescriptor { [[Value]]: V, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }.
  2. Return ? DefinePropertyOrThrow(O, P, newDesc).
Note
This abstract operation creates a property whose attributes are set to the same defaults used for properties created by the ECMAScript language assignment operator except they are not enumerable. Normally, the property will not already exist. If it does exist and is not configurable or if O is not extensible, [[DefineOwnProperty]] will return false causing this operation to throw a TypeError exception.

8 Placeholder to ensure correct clause numbering

9 Placeholder to ensure correct clause numbering

10 Placeholder to ensure correct clause numbering

11 Placeholder to ensure correct clause numbering

12 Placeholder to ensure correct clause numbering

13 Placeholder to ensure correct clause numbering

14 Placeholder to ensure correct clause numbering

15 Placeholder to ensure correct clause numbering

16 Placeholder to ensure correct clause numbering

17 Placeholder to ensure correct clause numbering

18 Placeholder to ensure correct clause numbering

19 Placeholder to ensure correct clause numbering

20 Fundamental Objects

20.1 Placeholder to ensure correct clause numbering

20.2 Placeholder to ensure correct clause numbering

20.3 Placeholder to ensure correct clause numbering

20.4 Placeholder to ensure correct clause numbering

20.5 Error Objects

20.5.1 The Error Constructor

20.5.1.1 Error ( message [ , options ] )

When the Error function is called with argument message and optional argument options, the following steps are taken:

  1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget.
  2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%Error.prototype%", « [[ErrorData]] »).
  3. If message is not undefined, then
    1. Let msg be ? ToString(message).
    2. Let msgDesc be the PropertyDescriptor { [[Value]]: msg, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }.
    3. Perform ! DefinePropertyOrThrow(O, "message", msgDesc).
    4. Perform ! CreateNonEnumerableDataPropertyOrThrow(O, "message", msg).
  4. Perform ? InstallErrorCause(O, options).
  5. Return O.

20.5.2 Placeholder to ensure correct clause numbering

20.5.3 Placeholder to ensure correct clause numbering

20.5.4 Placeholder to ensure correct clause numbering

20.5.5 Placeholder to ensure correct clause numbering

20.5.6 NativeError Object Structure

20.5.6.1 The NativeError Constructors

20.5.6.1.1 NativeError ( message [ , options ] )

When a NativeError function is called with argument message and optional argument options, the following steps are taken:

  1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget.
  2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%NativeError.prototype%", « [[ErrorData]] »).
  3. If message is not undefined, then
    1. Let msg be ? ToString(message).
    2. Let msgDesc be the PropertyDescriptor { [[Value]]: msg, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }.
    3. Perform ! DefinePropertyOrThrow(O, "message", msgDesc).
    4. Perform ! CreateNonEnumerableDataPropertyOrThrow(O, "message", msg).
  4. Perform ? InstallErrorCause(O, options).
  5. Return O.

The actual value of the string passed in step 2 is either "%EvalError.prototype%", "%RangeError.prototype%", "%ReferenceError.prototype%", "%SyntaxError.prototype%", "%TypeError.prototype%", or "%URIError.prototype%" corresponding to which NativeError constructor is being defined.

20.5.7 AggregateError Objects

20.5.7.1 The AggregateError Constructor

20.5.7.1.1 AggregateError ( errors, message [ , options ] )

When the AggregateError function is called with arguments errors and, message, and optional argument options, the following steps are taken:

  1. If NewTarget is undefined, let newTarget be the active function object; else let newTarget be NewTarget.
  2. Let O be ? OrdinaryCreateFromConstructor(newTarget, "%AggregateError.prototype%", « [[ErrorData]] »).
  3. If message is not undefined, then
    1. Let msg be ? ToString(message).
    2. Let msgDesc be the PropertyDescriptor { [[Value]]: msg, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }.
    3. Perform ! DefinePropertyOrThrow(O, "message", msgDesc).
    4. Perform ! CreateNonEnumerableDataPropertyOrThrow(O, "message", msg).
  4. Perform ? InstallErrorCause(O, options).
  5. Let errorsList be ? IterableToList(errors).
  6. Perform ! DefinePropertyOrThrow(O, "errors", PropertyDescriptor { [[Configurable]]: true, [[Enumerable]]: false, [[Writable]]: true, [[Value]]: ! CreateArrayFromList(errorsList) }).
  7. Return O.

20.5.8 Abstract Operations for Error Objects

20.5.8.1 InstallErrorCause ( O, options )

The abstract operation InstallErrorCause takes arguments O (an Object) and options. It is used to create "cause" property on O when the "cause" property is present on options. It performs the following steps when called:

  1. If Type(options) is Object and ? HasProperty(options, "cause") is true, then
    1. Let cause be ? Get(options, "cause").
    2. Perform ! CreateNonEnumerableDataPropertyOrThrow(O, "cause", cause).
  2. Return NormalCompletion(undefined).

A Copyright & Software License

Copyright Notice

© 2021 Chengzhong Wu, Hemanth HM, Ecma International

Software License

All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the authors nor Ecma International may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.