@@ -265,7 +265,7 @@ export class Cc65DebugSession extends LoggingDebugSession {
265265 }
266266 case "setBreakpoints" : {
267267 const result = response as DebugProtocol . SetBreakpointsResponse ;
268- const { breakpoints } = result . body ;
268+ const { breakpoints = [ ] } = result . body || { breakpoints : [ ] } ;
269269 const requestBreakpoints = this . _requestBreakpoints . get ( response . request_seq ) ;
270270 this . _requestBreakpoints . delete ( response . request_seq ) ;
271271 if ( ! requestBreakpoints ) {
@@ -276,20 +276,28 @@ export class Cc65DebugSession extends LoggingDebugSession {
276276 } ) ;
277277 }
278278
279- result . body . breakpoints = requestBreakpoints . map ( ( bp ) => {
280- if ( typeof bp === "number" ) {
281- const res = breakpoints . shift ( ) ;
282- if ( res ) return res ;
283- throw new Error (
284- `SetBreakpoints ${ response . request_seq } returned less breakpoints than requested.` ,
285- ) ;
286- }
287- return {
288- verified : false ,
289- reason : "failed" ,
290- message : bp || undefined ,
291- } ;
292- } ) ;
279+ try {
280+ result . body . breakpoints = requestBreakpoints . map ( ( bp ) => {
281+ if ( typeof bp === "number" ) {
282+ const res = breakpoints . shift ( ) ;
283+ if ( res ) return res ;
284+ throw new Error (
285+ `SetBreakpoints ${ response . request_seq } returned less breakpoints than requested.` ,
286+ ) ;
287+ }
288+ return {
289+ verified : false ,
290+ reason : "failed" ,
291+ message : bp || undefined ,
292+ } ;
293+ } ) ;
294+ } catch ( error ) {
295+ return this . sendErrorResponse ( response , {
296+ id : ErrorCodes . DAP_PROTOCOL_VIOLATION ,
297+ format : String ( error ) ,
298+ showUser : true ,
299+ } ) ;
300+ }
293301
294302 return this . sendResponse ( result ) ;
295303 }
0 commit comments