Stage 1 Draft / January 25, 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 Placeholder to ensure correct clause numbering

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 Fundamental Objects

19.1 Placeholder to ensure correct clause numbering

19.2 Placeholder to ensure correct clause numbering

19.3 Placeholder to ensure correct clause numbering

19.4 Placeholder to ensure correct clause numbering

19.5 Error Objects

19.5.1 The Error Constructor

19.5.1.1 Error ( message [ , cause ] )

When the Error function is called with argument message and cause, 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. If cause is not undefined, then
    1. Let causeDesc be the PropertyDescriptor { [[Value]]: cause, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }.
    2. Perform ! DefinePropertyOrThrow(O, "cause", causeDesc).
  5. Return O.

19.5.2 Placeholder to ensure correct clause numbering

19.5.3 Placeholder to ensure correct clause numbering

19.5.4 Placeholder to ensure correct clause numbering

19.5.5 Placeholder to ensure correct clause numbering

19.5.6 NativeError Object Structure

19.5.6.1 The NativeError Constructors

19.5.6.1.1 NativeError ( message [ , cause ] )

When a NativeError function is called with argument message and cause, 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. If cause is not undefined, then
    1. Let causeDesc be the PropertyDescriptor { [[Value]]: cause, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }.
    2. Perform ! DefinePropertyOrThrow(O, "cause", causeDesc).
  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.

19.5.7 AggregateError Objects

19.5.7.1 The AggregateError Constructor

19.5.7.1.1 AggregateError ( errors, message [ , cause ] )

When the AggregateError function is called with arguments errors and, message, and cause, 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. If cause is not undefined, then
    1. Let causeDesc be the PropertyDescriptor { [[Value]]: cause, [[Writable]]: true, [[Enumerable]]: false, [[Configurable]]: true }.
    2. Perform ! DefinePropertyOrThrow(O, "cause", causeDesc).
  5. Let errorsList be ? IterableToList(errors).
  6. Perform ! DefinePropertyOrThrow(O, "errors", PropertyDescriptor { [[Configurable]]: true, [[Enumerable]]: false, [[Writable]]: true, [[Value]]: ! CreateArrayFromList(errorsList) }).
  7. Return O.

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.