@@ -112,6 +112,11 @@ class StackTraceResult(NamedTuple):
112
112
total_frames : int
113
113
114
114
115
+ class InvalidThreadId (Exception ):
116
+ def __init__ (self , thread_id : Any ) -> None :
117
+ super ().__init__ (f"Invalid thread id { thread_id } " )
118
+
119
+
115
120
class StackFrameEntry :
116
121
def __init__ (
117
122
self ,
@@ -294,7 +299,7 @@ def stop(self) -> None:
294
299
@_logger .call
295
300
def continue_thread (self , thread_id : int ) -> None :
296
301
if self .main_thread is None or thread_id != self .main_thread .ident :
297
- raise RuntimeError ( "Invalid threadId" )
302
+ raise InvalidThreadId ( thread_id )
298
303
299
304
with self .condition :
300
305
self .state = State .Running
@@ -303,7 +308,7 @@ def continue_thread(self, thread_id: int) -> None:
303
308
@_logger .call
304
309
def pause_thread (self , thread_id : int ) -> None :
305
310
if self .main_thread is None or thread_id != self .main_thread .ident :
306
- raise RuntimeError ( "Invalid threadId" )
311
+ raise InvalidThreadId ( thread_id )
307
312
308
313
with self .condition :
309
314
self .requested_state = RequestedState .Pause
@@ -314,7 +319,7 @@ def pause_thread(self, thread_id: int) -> None:
314
319
@_logger .call
315
320
def next (self , thread_id : int , granularity : Optional [SteppingGranularity ] = None ) -> None :
316
321
if self .main_thread is None or thread_id != self .main_thread .ident :
317
- raise RuntimeError ( "Invalid threadId" )
322
+ raise InvalidThreadId ( thread_id )
318
323
319
324
with self .condition :
320
325
self .state = State .Running
@@ -346,7 +351,7 @@ def step_in(
346
351
self , thread_id : int , target_id : Optional [int ] = None , granularity : Optional [SteppingGranularity ] = None
347
352
) -> None :
348
353
if self .main_thread is None or thread_id != self .main_thread .ident :
349
- raise RuntimeError ( "Invalid threadId" )
354
+ raise InvalidThreadId ( thread_id )
350
355
351
356
with self .condition :
352
357
self .requested_state = RequestedState .StepIn
@@ -357,7 +362,7 @@ def step_in(
357
362
@_logger .call
358
363
def step_out (self , thread_id : int , granularity : Optional [SteppingGranularity ] = None ) -> None :
359
364
if self .main_thread is None or thread_id != self .main_thread .ident :
360
- raise RuntimeError ( "Invalid threadId" )
365
+ raise InvalidThreadId ( thread_id )
361
366
362
367
with self .condition :
363
368
self .requested_state = RequestedState .StepOut
@@ -384,7 +389,7 @@ def step_out(self, thread_id: int, granularity: Optional[SteppingGranularity] =
384
389
self .condition .notify_all ()
385
390
386
391
@event
387
- def send_event (sender , event : Event ) -> None :
392
+ def send_event (sender , event : Event ) -> None : # NOSONAR
388
393
...
389
394
390
395
def set_breakpoints (
@@ -862,6 +867,9 @@ def get_stack_trace(
862
867
levels : Optional [int ] = None ,
863
868
format : Optional [StackFrameFormat ] = None ,
864
869
) -> StackTraceResult :
870
+ if self .main_thread is None or thread_id != self .main_thread .ident :
871
+ raise InvalidThreadId (thread_id )
872
+
865
873
start_frame = start_frame or 0
866
874
levels = start_frame + (levels or len (self .stack_frames ))
867
875
0 commit comments