Skip to content

Commit

Permalink
Display thrown exception upon starting debug session in error dialog.
Browse files Browse the repository at this point in the history
  • Loading branch information
martomo committed Jan 7, 2018
1 parent 34efb72 commit 66a36ef
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
13 changes: 8 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,14 @@ def run(self, launch_browser=False, restart=False):
threading.Thread(target=self.listen).start()

def listen(self):
# Start listening for response from debugger engine
S.SESSION.listen()
# On connect run method which handles connection
if S.SESSION and S.SESSION.connected:
sublime.set_timeout(self.connected, 0)
try:
# Start listening for response from debugger engine
S.SESSION.listen()
# On connect run method which handles connection
if S.SESSION and S.SESSION.connected:
sublime.set_timeout(self.connected, 0)
except (protocol.ProtocolListenException) as e:
sublime.error_message('Unable to start Xdebug debugging session.\n\n%s' % e)

def connected(self):
sublime.set_timeout(lambda: sublime.status_message('Xdebug: Connected'), 100)
Expand Down
8 changes: 6 additions & 2 deletions xdebug/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def listen(self):
self.socket = None
except:
e = sys.exc_info()[1]
raise ProtocolConnectionException(e)
raise ProtocolListenException(e)

# Accept incoming connection on configured port
while self.listening:
Expand Down Expand Up @@ -276,7 +276,7 @@ def listen(self):
# Return socket connection
return self.socket
else:
raise ProtocolConnectionException('Could not create socket server.')
raise ProtocolListenException('Could not create socket server.')


class ProtocolException(Exception):
Expand All @@ -285,3 +285,7 @@ class ProtocolException(Exception):

class ProtocolConnectionException(ProtocolException):
pass


class ProtocolListenException(ProtocolException):
pass

0 comments on commit 66a36ef

Please sign in to comment.