@@ -135,7 +135,7 @@ def as_dict(self):
135135 return source_dict
136136
137137
138- class NotSupportedError (Exception ):
138+ class NotSupportedError (KeyError ):
139139 """Raised if a feature is not supported due to its capabilities."""
140140
141141
@@ -495,11 +495,13 @@ def wait_for_terminated(self, timeout: Optional[float] = None):
495495 raise ValueError ("didn't get terminated event" )
496496 return event_dict
497497
498- def get_capability (self , key , default = None ):
498+ def get_capability (self , key ):
499499 """Get a value for the given key if it there is a key/value pair in
500500 the capabilities reported by the adapter.
501501 """
502- return self .capabilities .get (key , default )
502+ if key in self .capabilities :
503+ return self .capabilities [key ]
504+ raise NotSupportedError (key )
503505
504506 def get_threads (self ):
505507 if self .threads is None :
@@ -767,8 +769,7 @@ def request_continue(self, threadId=None, singleThread=False):
767769 def request_restart (self , restartArguments = None ):
768770 if self .exit_status is not None :
769771 raise ValueError ("request_restart called after process exited" )
770- if not self .get_capability ("supportsRestartRequest" , False ):
771- raise NotSupportedError ("supportsRestartRequest is not set" )
772+ self .get_capability ("supportsRestartRequest" )
772773 command_dict = {
773774 "command" : "restart" ,
774775 "type" : "request" ,
@@ -981,8 +982,7 @@ def request_stepIn(self, threadId, targetId, granularity="statement"):
981982 def request_stepInTargets (self , frameId ):
982983 if self .exit_status is not None :
983984 raise ValueError ("request_stepInTargets called after process exited" )
984- if not self .get_capability ("supportsStepInTargetsRequest" , False ):
985- raise NotSupportedError ("supportsStepInTargetsRequest is not set" )
985+ self .get_capability ("supportsStepInTargetsRequest" )
986986 args_dict = {"frameId" : frameId }
987987 command_dict = {
988988 "command" : "stepInTargets" ,
0 commit comments