@@ -325,6 +325,13 @@ function toCallback(promise, callback) {
325325 . then ( callback . bind ( null , null ) , callback ) ;
326326}
327327
328+ function unpackError ( { code, message, data } ) {
329+ const err = new Error ( `${ message } - ${ data } ` ) ;
330+ err . code = code ;
331+ Error . captureStackTrace ( err , unpackError ) ;
332+ return err ;
333+ }
334+
328335class Client extends events . EventEmitter {
329336 constructor ( ) {
330337 super ( ) ;
@@ -374,7 +381,7 @@ class Client extends events.EventEmitter {
374381 return new Promise ( ( resolve , reject ) => {
375382 const data = { id : ++ this . _lastId , method, params } ;
376383 this . _pending [ data . id ] = ( error , result ) => {
377- if ( error ) reject ( error ) ;
384+ if ( error ) reject ( unpackError ( error ) ) ;
378385 else resolve ( isEmpty ( result ) ? undefined : result ) ;
379386 } ;
380387 const json = JSON . stringify ( data ) ;
@@ -470,7 +477,7 @@ function createCommandContext(inspector) {
470477 const scripts = { } ;
471478 const watchedExpressions = [ ] ;
472479
473- const breakPoints = new Map ( ) ;
480+ const knownBreakpoints = new Map ( ) ;
474481
475482 // Clear current line
476483 function clearline ( ) {
@@ -529,7 +536,7 @@ function createCommandContext(inspector) {
529536
530537 setBreakpoint ( script , line , condition , silent ) {
531538 const registerBreakpoint = ( { breakpointId, actualLocation } ) => {
532- breakPoints . set ( breakpointId , actualLocation ) ;
539+ knownBreakpoints . set ( breakpointId , actualLocation ) ;
533540 } ;
534541
535542 // setBreakpoint()
@@ -538,6 +545,15 @@ function createCommandContext(inspector) {
538545 return Debugger . setBreakpoint ( { location : currentSourceLocation , condition } )
539546 . then ( registerBreakpoint ) ;
540547 }
548+
549+ // setBreakpoint(line)
550+ if ( line === undefined && typeof script === 'number' ) {
551+ const location = Object . assign ( { } , currentSourceLocation , {
552+ lineNumber : script - 1 ,
553+ } ) ;
554+ return Debugger . setBreakpoint ( { location, condition } )
555+ . then ( registerBreakpoint ) ;
556+ }
541557 throw new Error ( 'Not implemented' ) ;
542558 } ,
543559
@@ -589,7 +605,7 @@ function createCommandContext(inspector) {
589605 }
590606
591607 let isBreakpoint = false ;
592- breakPoints . forEach ( actualLocation => {
608+ knownBreakpoints . forEach ( actualLocation => {
593609 if ( actualLocation . scriptId === scriptId && ( actualLocation . lineNumber + 1 ) === i ) {
594610 isBreakpoint = true ;
595611 }
0 commit comments