Skip to content

Poor wording for Error cause, and inaccurate description of location #17610

@ghost

Description

MDN URL

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error

What specific section or headline is this issue about?

Properties > error.prototype.cause

What information was incorrect, unhelpful, or incomplete?

Error cause. If an error is caught and re-thrown, this property should contain the original error.

This makes me think along the lines of literally

try {
 ...
 try {
  ...
 } catch (exception) {
  // throw it again
  throw exception;
 }
} catch (exception) {
 // it has a .cause now!
 const { cause } = exception;
}

which isn't accurate at all.

On another note, it says Error.prototype.cause, but this is actually an OwnProperty.
See, https://tc39.es/ecma262/multipage/fundamental-objects.html#sec-installerrorcause.
I don't think that any articles properly make this distinction, nor that there may be infrastructure or precedent for doing so.

What did you expect to see?

The cause is supplied by the code that throws the error object, this should be clarified.

Do you have any supporting links, references, or citations?

No response

Do you have anything more you want to share?

No response

MDN metadata

Page report details

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions