Skip to content

Commit

Permalink
src: use internal/errors for startSigintWatchdog
Browse files Browse the repository at this point in the history
Move the throw out of c++ and into js using internal/errors
  • Loading branch information
jasnell committed Oct 30, 2017
1 parent 64168eb commit 0d89d4d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
8 changes: 8 additions & 0 deletions doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -1247,6 +1247,14 @@ range.

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

<a id="ERR_REPL_STARTSIGINTWATCHDOG_FAILED"></a>
### ERR_REPL_STARTSIGINTWATCHDOG_FAILED

The `SigintWatchdog` is an internal utility used by the `repl` module to
monitor for interupt (`SIGINT`) signals received by the process. If this
utility cannot be started, the `repl` will not function correctly, so an
error is thrown.

<a id="ERR_REQUIRE_ESM"></a>
### ERR_REQUIRE_ESM

Expand Down
1 change: 1 addition & 0 deletions lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ E('ERR_NO_LONGER_SUPPORTED', '%s is no longer supported');
E('ERR_OUTOFMEMORY', 'Out of memory');
E('ERR_OUT_OF_RANGE', 'The "%s" argument is out of range');
E('ERR_PARSE_HISTORY_DATA', 'Could not parse history data in %s');
E('ERR_REPL_STARTSIGINTWATCHDOG_FAILED', 'startSigintWatchdog Failed');
E('ERR_REQUIRE_ESM', 'Must use import to load ES Module: %s');
E('ERR_SERVER_ALREADY_LISTEN',
'Listen method has been called more than once without closing.');
Expand Down
3 changes: 2 additions & 1 deletion lib/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ function REPLServer(prompt,
if (self.breakEvalOnSigint) {
// Start the SIGINT watchdog before entering raw mode so that a very
// quick Ctrl+C doesn't lead to aborting the process completely.
utilBinding.startSigintWatchdog();
if (!utilBinding.startSigintWatchdog())
throw new errors.Error('ERR_REPL_STARTSIGINTWATCHDOG_FAILED');
previouslyInRawMode = self._setRawMode(false);
}

Expand Down
5 changes: 1 addition & 4 deletions src/node_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,7 @@ static void SetHiddenValue(const FunctionCallbackInfo<Value>& args) {

void StartSigintWatchdog(const FunctionCallbackInfo<Value>& args) {
int ret = SigintWatchdogHelper::GetInstance()->Start();
if (ret != 0) {
Environment* env = Environment::GetCurrent(args);
env->ThrowErrnoException(ret, "StartSigintWatchdog");
}
args.GetReturnValue().Set(ret == 0);
}


Expand Down

0 comments on commit 0d89d4d

Please sign in to comment.