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+
5355const FS = require ( 'fs' ) ;
5456const Path = require ( 'path' ) ;
5557const Repl = require ( 'repl' ) ;
@@ -176,7 +178,7 @@ function extractErrorMessage(stack) {
176178
177179function 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