From ab87fc30a3b55b94dc9105b710ce70d2f6be4225 Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Tue, 22 Mar 2016 17:47:09 +0000 Subject: [PATCH] repr errors before creating APIGenericErrorResponse's Many of the errors that Voltron encounters __str__ into an empty string, but __repr__ into a useful string describing the error. --- examples/angularview/angularview.py | 2 +- voltron/core.py | 2 +- voltron/plugins/api/breakpoints.py | 2 +- voltron/plugins/api/command.py | 2 +- voltron/plugins/api/dereference.py | 2 +- voltron/plugins/api/memory.py | 2 +- voltron/plugins/api/registers.py | 2 +- voltron/plugins/api/targets.py | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/examples/angularview/angularview.py b/examples/angularview/angularview.py index 56476b9..d173e12 100644 --- a/examples/angularview/angularview.py +++ b/examples/angularview/angularview.py @@ -21,7 +21,7 @@ class FormatDisassemblyRequest(APIRequest): res = FormatDisassemblyResponse( disassembly=pygments.highlight(self.disassembly.strip(), LLDBIntelLexer(), pygments.formatters.HtmlFormatter())) except Exception as e: - msg = "Exception formatting disassembly: {}".format(e) + msg = "Exception formatting disassembly: {}".format(repr(e)) log.exception(msg) res = APIGenericErrorResponse(msg) diff --git a/voltron/core.py b/voltron/core.py index 15da555..56f6c97 100644 --- a/voltron/core.py +++ b/voltron/core.py @@ -250,7 +250,7 @@ class Server(object): try: res = req.dispatch() except Exception as e: - msg = "Exception raised while dispatching request: {}".format(e) + msg = "Exception raised while dispatching request: {}".format(repr(e)) log.exception(msg) res = APIGenericErrorResponse(msg) diff --git a/voltron/plugins/api/breakpoints.py b/voltron/plugins/api/breakpoints.py index 88755e4..0ba69b5 100644 --- a/voltron/plugins/api/breakpoints.py +++ b/voltron/plugins/api/breakpoints.py @@ -29,7 +29,7 @@ class APIBreakpointsRequest(APIRequest): except NoSuchTargetException: res = APINoSuchTargetErrorResponse() except Exception as e: - msg = "Exception getting breakpoints: {}".format(e) + msg = "Exception getting breakpoints: {}".format(repr(e)) log.exception(msg) res = APIGenericErrorResponse(msg) diff --git a/voltron/plugins/api/command.py b/voltron/plugins/api/command.py index 9d04631..bf26a24 100644 --- a/voltron/plugins/api/command.py +++ b/voltron/plugins/api/command.py @@ -30,7 +30,7 @@ class APICommandRequest(APIRequest): except NoSuchTargetException: res = APINoSuchTargetErrorResponse() except Exception as e: - msg = "Exception executing debugger command: {}".format(e) + msg = "Exception executing debugger command: {}".format(repr(e)) log.exception(msg) res = APIGenericErrorResponse(msg) diff --git a/voltron/plugins/api/dereference.py b/voltron/plugins/api/dereference.py index cc2fb6c..3ffeda9 100644 --- a/voltron/plugins/api/dereference.py +++ b/voltron/plugins/api/dereference.py @@ -31,7 +31,7 @@ class APIDerefRequest(APIRequest): except NoSuchTargetException: res = APINoSuchTargetErrorResponse() except Exception as e: - msg = "Exception dereferencing pointer: {}".format(e) + msg = "Exception dereferencing pointer: {}".format(repr(e)) log.exception(msg) res = APIGenericErrorResponse(msg) diff --git a/voltron/plugins/api/memory.py b/voltron/plugins/api/memory.py index ab1fbce..51bb708 100644 --- a/voltron/plugins/api/memory.py +++ b/voltron/plugins/api/memory.py @@ -104,7 +104,7 @@ class APIMemoryRequest(APIRequest): except NoSuchTargetException: res = APINoSuchTargetErrorResponse() except Exception as e: - msg = "Exception getting memory from debugger: {}".format(e) + msg = "Exception getting memory from debugger: {}".format(repr(e)) log.exception(msg) res = APIGenericErrorResponse(msg) diff --git a/voltron/plugins/api/registers.py b/voltron/plugins/api/registers.py index d1a273c..697d41f 100644 --- a/voltron/plugins/api/registers.py +++ b/voltron/plugins/api/registers.py @@ -43,7 +43,7 @@ class APIRegistersRequest(APIRequest): except NoSuchTargetException: res = APINoSuchTargetErrorResponse() except Exception as e: - msg = "Exception getting registers from debugger: {}".format(e) + msg = "Exception getting registers from debugger: {}".format(repr(e)) log.exception(msg) res = APIGenericErrorResponse(msg) diff --git a/voltron/plugins/api/targets.py b/voltron/plugins/api/targets.py index 0ee205f..2ed63a2 100644 --- a/voltron/plugins/api/targets.py +++ b/voltron/plugins/api/targets.py @@ -26,7 +26,7 @@ class APITargetsRequest(APIRequest): except NoSuchTargetException: res = APINoSuchTargetErrorResponse() except Exception as e: - msg = "Exception getting targets from debugger: {}".format(e) + msg = "Exception getting targets from debugger: {}".format(repr(e)) log.exception(msg) res = APIGenericErrorResponse(msg)