From 132c7697668c0f4a4f1ca19e5229449aeedc8546 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Fri, 18 Dec 2015 19:58:09 +0200 Subject: [PATCH] Better error handling --- platformio/__main__.py | 6 +++++- platformio/telemetry.py | 10 ++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/platformio/__main__.py b/platformio/__main__.py index 813558bb..cafaec6c 100644 --- a/platformio/__main__.py +++ b/platformio/__main__.py @@ -109,7 +109,11 @@ def main(): An unexpected error occurred. Further steps: * Verify that you have the latest version of PlatformIO using - `platformio upgrade` command + `pip install -U platformio` command + +* Try to find answer in FAQ Troubleshooting section + http://docs.platformio.org/en/latest/faq.html + * Report this problem to the developers https://github.com/platformio/platformio/issues diff --git a/platformio/telemetry.py b/platformio/telemetry.py index 43a501dd..6a4c163d 100644 --- a/platformio/telemetry.py +++ b/platformio/telemetry.py @@ -22,6 +22,7 @@ import uuid from collections import deque from os import getenv from time import sleep, time +from traceback import format_exc import click import requests @@ -289,12 +290,13 @@ def on_event(category, action, label=None, value=None, screen_name=None): def on_exception(e): if isinstance(e, exception.AbortedByUser): return - mp = MeasurementProtocol() - mp['exd'] = "%s: %s" % (type(e).__name__, e) - mp['exf'] = int(any([ + is_crash = any([ not isinstance(e, exception.PlatformioException), "Error" in e.__class__.__name__ - ])) + ]) + mp = MeasurementProtocol() + mp['exd'] = "%s: %s" % (type(e).__name__, format_exc() if is_crash else e) + mp['exf'] = 1 if is_crash else 0 mp.send("exception")