Skip to content

Commit

Permalink
Don't show an error when attempting to stop the debugger when there i…
Browse files Browse the repository at this point in the history
…s no active session to stop
  • Loading branch information
daveleroy committed Apr 1, 2023
1 parent 60cf05b commit c087939
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
6 changes: 4 additions & 2 deletions modules/core/error.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

class Error(Exception):
def __init__(self, format: str):
super().__init__(format)
message = 'Unknown Error Occured'

def __init__(self, message: str|None = None):
super().__init__(message or self.message or 'Unknown Error Occured')
5 changes: 4 additions & 1 deletion modules/dap/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
SourceLocation,
)

from .error import Error, Json
from .error import (
Error,
NoActiveSessionError,
)

from .dap import (
StackFrame,
Expand Down
2 changes: 2 additions & 0 deletions modules/dap/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ def from_message(message: dap.Message):
return Error(format, message.url, message.urlLabel)


class NoActiveSessionError(core.Error):
message = 'No Active Debug Session'
3 changes: 2 additions & 1 deletion modules/debugger.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ async def stop(self, session: dap.Session|None = None) -> None:

await session_stop

except dap.NoActiveSessionError: ...
except core.Error as e: self.console.error(f'Unable to stop: {e}')

@property
Expand All @@ -461,7 +462,7 @@ def is_active(self):
@property
def active(self):
if not self.session:
raise core.Error('No Active Debug Sessions')
raise dap.NoActiveSessionError()
return self.session

@active.setter
Expand Down

0 comments on commit c087939

Please sign in to comment.