diff --git a/plugin/python/vdebug/dbgp.py b/plugin/python/vdebug/dbgp.py index fcce0d2e..92b03eeb 100644 --- a/plugin/python/vdebug/dbgp.py +++ b/plugin/python/vdebug/dbgp.py @@ -24,17 +24,22 @@ def __parse_error(self): in the response, then raise it as a DBGPError.""" xml = self.as_xml() err_el = xml.find('%serror' % self.ns) - code = err_el.get("code") - if code is None: - raise ResponseError( - "Missing error code in response", - self.response) - msg_el = err_el.find('%smessage' % self.ns) - if msg_el is None: - raise ResponseError( - "Missing error message in response", - self.response) - raise DBGPError(msg_el.text,code) + if err_el is None: + raise DBGPError("Could not parse error from return XML",1) + else: + code = err_el.get("code") + if code is None: + raise ResponseError( + "Missing error code in response", + self.response) + elif int(code) == 4: + raise CmdNotImplementedError('Command not implemented') + msg_el = err_el.find('%smessage' % self.ns) + if msg_el is None: + raise ResponseError( + "Missing error message in response", + self.response) + raise DBGPError(msg_el.text,code) def get_cmd(self): """Get the command that created this response.""" @@ -60,8 +65,17 @@ def as_xml(self): """ if self.xml == None: self.xml = ET.fromstring(self.response) + self.__determine_ns() return self.xml + def __determine_ns(self): + tag_repr = str(self.xml.tag) + if tag_repr[0] != '{': + raise DBGPError('Invalid or missing XML namespace',1) + else: + ns_parts = tag_repr.split('}') + self.ns = ns_parts[0] + '}' + def __str__(self): return self.as_string() @@ -665,6 +679,10 @@ class DBGPError(Exception): """Raised when the debugger returns an error message.""" pass +class CmdNotImplementedError(Exception): + """Raised when the debugger returns an error message.""" + pass + class EvalError(Exception): """Raised when some evaluated code is invalid.""" pass diff --git a/plugin/python/vdebug/opts.py b/plugin/python/vdebug/opts.py index 6f33d4f8..f2f14064 100644 --- a/plugin/python/vdebug/opts.py +++ b/plugin/python/vdebug/opts.py @@ -31,6 +31,11 @@ def get(cls,name,as_type = str): else: raise OptionsError, "No option with key '%s'" % name + @classmethod + def overwrite(cls,name,value): + inst = cls.inst() + inst.options[name] = value + @classmethod def isset(cls,name): """Checks whether the option exists and is set. diff --git a/plugin/python/vdebug/runner.py b/plugin/python/vdebug/runner.py index 402f08b0..656cb9f5 100644 --- a/plugin/python/vdebug/runner.py +++ b/plugin/python/vdebug/runner.py @@ -287,7 +287,12 @@ def close_connection(self,stop = True): vdebug.log.Log("Closing the connection") if stop: if vdebug.opts.Options.get('on_close') == 'detach': - self.api.detach() + try: + self.api.detach() + except vdebug.dbgp.CmdNotImplementedError: + self.ui.error('Detach is not supported by the debugger, stopping instead') + vdebug.opts.Options.overwrite('on_close','stop') + self.api.stop() else: self.api.stop() self.api.conn.close()