Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b43cb69

Browse filesBrowse files
Trottdanielleadams
authored andcommitted
debugger: use error codes in debugger REPL
PR-URL: #39024 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jan Krems <jan.krems@gmail.com>
1 parent dc92181 commit b43cb69
Copy full SHA for b43cb69

File tree

Expand file treeCollapse file tree

1 file changed

+9
-9
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-9
lines changed
Open diff view settings
Collapse file

‎lib/internal/inspector/inspect_repl.js‎

Copy file name to clipboardExpand all lines: lib/internal/inspector/inspect_repl.js
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// TODO(trott): enable ESLint
2-
/* eslint-disable getter-return, no-restricted-syntax */
2+
/* eslint-disable getter-return */
33

44
'use strict';
55

@@ -18,7 +18,6 @@ const {
1818
ArrayPrototypeSome,
1919
ArrayPrototypeSplice,
2020
Date,
21-
Error,
2221
FunctionPrototypeCall,
2322
JSONStringify,
2423
MathMax,
@@ -47,9 +46,12 @@ const {
4746
StringPrototypeStartsWith,
4847
StringPrototypeToUpperCase,
4948
StringPrototypeTrim,
50-
TypeError,
5149
} = primordials;
5250

51+
const { ERR_DEBUGGER_ERROR } = require('internal/errors').codes;
52+
53+
const { validateString } = require('internal/validators');
54+
5355
const FS = require('fs');
5456
const Path = require('path');
5557
const Repl = require('repl');
@@ -176,7 +178,7 @@ function extractErrorMessage(stack) {
176178

177179
function convertResultToError(result) {
178180
const { className, description } = result;
179-
const err = new Error(extractErrorMessage(description));
181+
const err = new ERR_DEBUGGER_ERROR(extractErrorMessage(description));
180182
err.stack = description;
181183
ObjectDefineProperty(err, 'name', { value: className });
182184
return err;
@@ -357,7 +359,7 @@ function createRepl(inspector) {
357359

358360
function getCurrentLocation() {
359361
if (!selectedFrame) {
360-
throw new Error('Requires execution to be paused');
362+
throw new ERR_DEBUGGER_ERROR('Requires execution to be paused');
361363
}
362364
return selectedFrame.location;
363365
}
@@ -543,7 +545,7 @@ function createRepl(inspector) {
543545
// Repl asked for scope variables
544546
if (code === '.scope') {
545547
if (!selectedFrame) {
546-
throw new Error('Requires execution to be paused');
548+
throw new ERR_DEBUGGER_ERROR('Requires execution to be paused');
547549
}
548550
const scopes = await selectedFrame.loadScopes();
549551
return ArrayPrototypeMap(scopes, (scope) => scope.completionGroup);
@@ -706,9 +708,7 @@ function createRepl(inspector) {
706708
registerBreakpoint);
707709
}
708710

709-
if (typeof script !== 'string') {
710-
throw new TypeError(`setBreakpoint() expects a string, got ${script}`);
711-
}
711+
validateString(script, 'script');
712712

713713
// setBreakpoint('fn()'): Break when a function is called
714714
if (StringPrototypeEndsWith(script, '()')) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.