Skip to content

Commit 0d89d4d

Browse files
committed
src: use internal/errors for startSigintWatchdog
Move the throw out of c++ and into js using internal/errors
1 parent 64168eb commit 0d89d4d

File tree

4 files changed

+12
-5
lines changed

4 files changed

+12
-5
lines changed

doc/api/errors.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,14 @@ range.
12471247

12481248
Used by the `REPL` module when it cannot parse data from the REPL history file.
12491249

1250+
<a id="ERR_REPL_STARTSIGINTWATCHDOG_FAILED"></a>
1251+
### ERR_REPL_STARTSIGINTWATCHDOG_FAILED
1252+
1253+
The `SigintWatchdog` is an internal utility used by the `repl` module to
1254+
monitor for interupt (`SIGINT`) signals received by the process. If this
1255+
utility cannot be started, the `repl` will not function correctly, so an
1256+
error is thrown.
1257+
12501258
<a id="ERR_REQUIRE_ESM"></a>
12511259
### ERR_REQUIRE_ESM
12521260

lib/internal/errors.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ E('ERR_NO_LONGER_SUPPORTED', '%s is no longer supported');
310310
E('ERR_OUTOFMEMORY', 'Out of memory');
311311
E('ERR_OUT_OF_RANGE', 'The "%s" argument is out of range');
312312
E('ERR_PARSE_HISTORY_DATA', 'Could not parse history data in %s');
313+
E('ERR_REPL_STARTSIGINTWATCHDOG_FAILED', 'startSigintWatchdog Failed');
313314
E('ERR_REQUIRE_ESM', 'Must use import to load ES Module: %s');
314315
E('ERR_SERVER_ALREADY_LISTEN',
315316
'Listen method has been called more than once without closing.');

lib/repl.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,8 @@ function REPLServer(prompt,
227227
if (self.breakEvalOnSigint) {
228228
// Start the SIGINT watchdog before entering raw mode so that a very
229229
// quick Ctrl+C doesn't lead to aborting the process completely.
230-
utilBinding.startSigintWatchdog();
230+
if (!utilBinding.startSigintWatchdog())
231+
throw new errors.Error('ERR_REPL_STARTSIGINTWATCHDOG_FAILED');
231232
previouslyInRawMode = self._setRawMode(false);
232233
}
233234

src/node_util.cc

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,7 @@ static void SetHiddenValue(const FunctionCallbackInfo<Value>& args) {
135135

136136
void StartSigintWatchdog(const FunctionCallbackInfo<Value>& args) {
137137
int ret = SigintWatchdogHelper::GetInstance()->Start();
138-
if (ret != 0) {
139-
Environment* env = Environment::GetCurrent(args);
140-
env->ThrowErrnoException(ret, "StartSigintWatchdog");
141-
}
138+
args.GetReturnValue().Set(ret == 0);
142139
}
143140

144141

0 commit comments

Comments
 (0)