Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2021-06-13 15:00:09 +0300
committerRich Trott <rtrott@gmail.com>2021-06-16 04:43:12 +0300
commitfa009e1428f3f59cfed9cf96c59291594b6ac089 (patch)
tree92d4aa6602ad77f9ce32eb074d1e55b3c86e5a25 /lib
parentc22eec85b477f73e95235caadbcaa2bb433e5f49 (diff)
debugger: use error codes in debugger REPL
PR-URL: https://github.com/nodejs/node/pull/39024 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/inspector/inspect_repl.js18
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/internal/inspector/inspect_repl.js b/lib/internal/inspector/inspect_repl.js
index 3cb4d52f43a..5393cb32718 100644
--- a/lib/internal/inspector/inspect_repl.js
+++ b/lib/internal/inspector/inspect_repl.js
@@ -1,5 +1,5 @@
// TODO(trott): enable ESLint
-/* eslint-disable getter-return, no-restricted-syntax */
+/* eslint-disable getter-return */
'use strict';
@@ -18,7 +18,6 @@ const {
ArrayPrototypeSome,
ArrayPrototypeSplice,
Date,
- Error,
FunctionPrototypeCall,
JSONStringify,
MathMax,
@@ -47,9 +46,12 @@ const {
StringPrototypeStartsWith,
StringPrototypeToUpperCase,
StringPrototypeTrim,
- TypeError,
} = primordials;
+const { ERR_DEBUGGER_ERROR } = require('internal/errors').codes;
+
+const { validateString } = require('internal/validators');
+
const FS = require('fs');
const Path = require('path');
const Repl = require('repl');
@@ -176,7 +178,7 @@ function extractErrorMessage(stack) {
function convertResultToError(result) {
const { className, description } = result;
- const err = new Error(extractErrorMessage(description));
+ const err = new ERR_DEBUGGER_ERROR(extractErrorMessage(description));
err.stack = description;
ObjectDefineProperty(err, 'name', { value: className });
return err;
@@ -357,7 +359,7 @@ function createRepl(inspector) {
function getCurrentLocation() {
if (!selectedFrame) {
- throw new Error('Requires execution to be paused');
+ throw new ERR_DEBUGGER_ERROR('Requires execution to be paused');
}
return selectedFrame.location;
}
@@ -543,7 +545,7 @@ function createRepl(inspector) {
// Repl asked for scope variables
if (code === '.scope') {
if (!selectedFrame) {
- throw new Error('Requires execution to be paused');
+ throw new ERR_DEBUGGER_ERROR('Requires execution to be paused');
}
const scopes = await selectedFrame.loadScopes();
return ArrayPrototypeMap(scopes, (scope) => scope.completionGroup);
@@ -706,9 +708,7 @@ function createRepl(inspector) {
registerBreakpoint);
}
- if (typeof script !== 'string') {
- throw new TypeError(`setBreakpoint() expects a string, got ${script}`);
- }
+ validateString(script, 'script');
// setBreakpoint('fn()'): Break when a function is called
if (StringPrototypeEndsWith(script, '()')) {