1
1
// TODO(trott): enable ESLint
2
- /* eslint-disable getter-return, no-restricted-syntax */
2
+ /* eslint-disable getter-return */
3
3
4
4
'use strict' ;
5
5
@@ -18,7 +18,6 @@ const {
18
18
ArrayPrototypeSome,
19
19
ArrayPrototypeSplice,
20
20
Date,
21
- Error,
22
21
FunctionPrototypeCall,
23
22
JSONStringify,
24
23
MathMax,
@@ -47,9 +46,12 @@ const {
47
46
StringPrototypeStartsWith,
48
47
StringPrototypeToUpperCase,
49
48
StringPrototypeTrim,
50
- TypeError,
51
49
} = primordials ;
52
50
51
+ const { ERR_DEBUGGER_ERROR } = require ( 'internal/errors' ) . codes ;
52
+
53
+ const { validateString } = require ( 'internal/validators' ) ;
54
+
53
55
const FS = require ( 'fs' ) ;
54
56
const Path = require ( 'path' ) ;
55
57
const Repl = require ( 'repl' ) ;
@@ -176,7 +178,7 @@ function extractErrorMessage(stack) {
176
178
177
179
function convertResultToError ( result ) {
178
180
const { className, description } = result ;
179
- const err = new Error ( extractErrorMessage ( description ) ) ;
181
+ const err = new ERR_DEBUGGER_ERROR ( extractErrorMessage ( description ) ) ;
180
182
err . stack = description ;
181
183
ObjectDefineProperty ( err , 'name' , { value : className } ) ;
182
184
return err ;
@@ -357,7 +359,7 @@ function createRepl(inspector) {
357
359
358
360
function getCurrentLocation ( ) {
359
361
if ( ! selectedFrame ) {
360
- throw new Error ( 'Requires execution to be paused' ) ;
362
+ throw new ERR_DEBUGGER_ERROR ( 'Requires execution to be paused' ) ;
361
363
}
362
364
return selectedFrame . location ;
363
365
}
@@ -543,7 +545,7 @@ function createRepl(inspector) {
543
545
// Repl asked for scope variables
544
546
if ( code === '.scope' ) {
545
547
if ( ! selectedFrame ) {
546
- throw new Error ( 'Requires execution to be paused' ) ;
548
+ throw new ERR_DEBUGGER_ERROR ( 'Requires execution to be paused' ) ;
547
549
}
548
550
const scopes = await selectedFrame . loadScopes ( ) ;
549
551
return ArrayPrototypeMap ( scopes , ( scope ) => scope . completionGroup ) ;
@@ -706,9 +708,7 @@ function createRepl(inspector) {
706
708
registerBreakpoint ) ;
707
709
}
708
710
709
- if ( typeof script !== 'string' ) {
710
- throw new TypeError ( `setBreakpoint() expects a string, got ${ script } ` ) ;
711
- }
711
+ validateString ( script , 'script' ) ;
712
712
713
713
// setBreakpoint('fn()'): Break when a function is called
714
714
if ( StringPrototypeEndsWith ( script , '()' ) ) {
0 commit comments