docs(async): add note about deadline() DOMException name of TimeoutError (#5833)

* docs(async): add note about deadline DOMException name of TimeoutError

* Document all cases for thrown error
This commit is contained in:
lionel-rowe 2024-08-28 13:46:19 +08:00 committed by GitHub
parent 29fdb0d536
commit 2e209c0ff6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -16,8 +16,12 @@ export interface DeadlineOptions {
* Note: Prefer to use {@linkcode AbortSignal.timeout} instead for the APIs
* that accept {@linkcode AbortSignal}.
*
* @throws {DOMException} When the provided duration runs out before resolving
* or if the optional signal is aborted, and `signal.reason` is undefined.
* @throws {DOMException & { name: "TimeoutError" }} If the provided duration
* runs out before resolving.
* @throws {DOMException & { name: "AbortError" }} If the optional signal is
* aborted with the default `reason` before resolving or timing out.
* @throws {AbortSignal["reason"]} If the optional signal is aborted with a
* custom `reason` before resolving or timing out.
* @typeParam T The type of the provided and returned promise.
* @param p The promise to make rejectable.
* @param ms Duration in milliseconds for when the promise should time out.