tc39 / proposal-cancelable-promises

Former home of the now-withdrawn cancelable promises proposal for JavaScript
Other
375 stars 29 forks source link

Not sure about "Not an Error" and "try ... else ..." #58

Closed doodadjs closed 7 years ago

doodadjs commented 7 years ago

I think the Cancel class could still inherit from Error. And instead of "try ... else ...", I'm thinking of :

try
    ....
catch(Cancel err) {
    ...
}
catch([TypeError, SyntaxError] err) {
    ...
}
...

EDIT: Fix markup

ljharb commented 7 years ago

That would be "catch guards", which would be an entirely different and complex proposal - and certainly not part of this one.

domenic commented 7 years ago

Yep. See the document in this repo explaining why cancelations are not errors. This is a fundamental part of the proposal and not going to change.

Volune commented 7 years ago

@ljharb Shouldn't the try ... else ... itself be part of another proposal, being a short syntax for a specific case of conditional catch.

I feel that the try ... else ... leaves a lot of questions

domenic commented 7 years ago

All of those questions have answers in this repository and the spec. Please read the material you are critiquing.

bergus commented 7 years ago

@domenic Those are all valid questions. Why else? does not answer the first, third and fourth questions. The spec proposal does answer the second and fifth question, but without explanation or discussion why that is so. #35 does make a case against try {…} catch(…) {…} else(…) {…} but not against try {…} else(…) {…} catch(…) {…}.