@@ -33,10 +33,13 @@ const {
|
33 | 33 | SymbolDispose, |
34 | 34 | } = primordials; |
35 | 35 | |
36 | | -const { codes: { |
37 | | -ERR_INVALID_ARG_VALUE, |
38 | | -ERR_USE_AFTER_CLOSE, |
39 | | -} } = require('internal/errors'); |
| 36 | +const { |
| 37 | + AbortError, |
| 38 | +codes: { |
| 39 | +ERR_INVALID_ARG_VALUE, |
| 40 | +ERR_USE_AFTER_CLOSE, |
| 41 | +}, |
| 42 | +} = require('internal/errors'); |
40 | 43 | |
41 | 44 | const { |
42 | 45 | validateAbortSignal, |
@@ -111,6 +114,7 @@ const kPrompt = Symbol('_prompt');
|
111 | 114 | const kPushToKillRing = Symbol('_pushToKillRing'); |
112 | 115 | const kPushToUndoStack = Symbol('_pushToUndoStack'); |
113 | 116 | const kQuestionCallback = Symbol('_questionCallback'); |
| 117 | +const kQuestionReject = Symbol('_questionReject'); |
114 | 118 | const kRedo = Symbol('_redo'); |
115 | 119 | const kRedoStack = Symbol('_redoStack'); |
116 | 120 | const kRefreshLine = Symbol('_refreshLine'); |
@@ -1126,6 +1130,7 @@ class Interface extends InterfaceConstructor {
|
1126 | 1130 | } else { |
1127 | 1131 | // This readline instance is finished |
1128 | 1132 | this.close(); |
| 1133 | +this[kQuestionReject]?.(new AbortError('Aborted with Ctrl+C')); |
1129 | 1134 | } |
1130 | 1135 | break; |
1131 | 1136 | |
@@ -1137,6 +1142,7 @@ class Interface extends InterfaceConstructor {
|
1137 | 1142 | if (this.cursor === 0 && this.line.length === 0) { |
1138 | 1143 | // This readline instance is finished |
1139 | 1144 | this.close(); |
| 1145 | +this[kQuestionReject]?.(new AbortError('Aborted with Ctrl+D')); |
1140 | 1146 | } else if (this.cursor < this.line.length) { |
1141 | 1147 | this[kDeleteRight](); |
1142 | 1148 | } |
@@ -1392,6 +1398,7 @@ module.exports = {
|
1392 | 1398 | kQuestion, |
1393 | 1399 | kQuestionCallback, |
1394 | 1400 | kQuestionCancel, |
| 1401 | + kQuestionReject, |
1395 | 1402 | kRefreshLine, |
1396 | 1403 | kSawKeyPress, |
1397 | 1404 | kSawReturnAt, |
|