| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e795547 commit 67124ac
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -157,15 +157,16 @@ Interface.prototype.question[promisify.custom] = function(query, options) { | |||
| 157 | 157 | options = typeof options === 'object' && options !== null ? options : {}; | |
| 158 | 158 | ||
| 159 | 159 | if (options.signal && options.signal.aborted) { | |
| 160 | - return PromiseReject(new AbortError()); | ||
| 160 | + return PromiseReject( | ||
| 161 | + new AbortError(undefined, { cause: options.signal.reason })); | ||
| 161 | 162 | } | |
| 162 | 163 | ||
| 163 | 164 | return new Promise((resolve, reject) => { | |
| 164 | 165 | let cb = resolve; | |
| 165 | 166 | ||
| 166 | 167 | if (options.signal) { | |
| 167 | 168 | const onAbort = () => { | |
| 168 | - reject(new AbortError()); | ||
| 169 | + reject(new AbortError(undefined, { cause: options.signal.reason })); | ||
| 169 | 170 | }; | |
| 170 | 171 | options.signal.addEventListener('abort', onAbort, { once: true }); | |
| 171 | 172 | cb = (answer) => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,12 +30,13 @@ class Interface extends _Interface { | |||
| 30 | 30 | if (options?.signal) { | |
| 31 | 31 | validateAbortSignal(options.signal, 'options.signal'); | |
| 32 | 32 | if (options.signal.aborted) { | |
| 33 | - return reject(new AbortError()); | ||
| 33 | + return reject( | ||
| 34 | + new AbortError(undefined, { cause: options.signal.reason })); | ||
| 34 | 35 | } | |
| 35 | 36 | ||
| 36 | 37 | const onAbort = () => { | |
| 37 | 38 | this[kQuestionCancel](); | |
| 38 | - reject(new AbortError()); | ||
| 39 | + reject(new AbortError(undefined, { cause: options.signal.reason })); | ||
| 39 | 40 | }; | |
| 40 | 41 | options.signal.addEventListener('abort', onAbort, { once: true }); | |
| 41 | 42 | cb = (answer) => { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -910,6 +910,15 @@ for (let i = 0; i < 12; i++) { | |||
| 910 | 910 | rli.close(); | |
| 911 | 911 | } | |
| 912 | 912 | ||
| 913 | + (async () => { | ||
| 914 | + const [rli] = getInterface({ terminal }); | ||
| 915 | + const signal = AbortSignal.abort('boom'); | ||
| 916 | + await assert.rejects(rli.question('hello', { signal }), { | ||
| 917 | + cause: 'boom', | ||
| 918 | + }); | ||
| 919 | + rli.close(); | ||
| 920 | + })().then(common.mustCall()); | ||
| 921 | + | ||
| 913 | 922 | // Throw an error when question is executed with an aborted signal | |
| 914 | 923 | { | |
| 915 | 924 | const ac = new AbortController(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments