From 292dc3fd7135ab503633aa2f9b92af3d7cd05e83 Mon Sep 17 00:00:00 2001 From: Ivan Kravets Date: Mon, 19 Jun 2023 11:40:40 +0300 Subject: [PATCH] Update user-related exceptions to UserSideException --- platformio/account/client.py | 6 +++--- platformio/package/exception.py | 8 ++++---- platformio/package/vcsclient.py | 4 ++-- platformio/platform/exception.py | 4 ++-- platformio/project/helpers.py | 2 +- platformio/telemetry.py | 2 ++ 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/platformio/account/client.py b/platformio/account/client.py index a898de48..06432144 100644 --- a/platformio/account/client.py +++ b/platformio/account/client.py @@ -16,7 +16,7 @@ import os import time from platformio import __accounts_api__, app -from platformio.exception import PlatformioException +from platformio.exception import PlatformioException, UserSideException from platformio.http import HTTPClient, HTTPClientError @@ -24,11 +24,11 @@ class AccountError(PlatformioException): MESSAGE = "{0}" -class AccountNotAuthorized(AccountError): +class AccountNotAuthorized(AccountError, UserSideException): MESSAGE = "You are not authorized! Please log in to PlatformIO Account." -class AccountAlreadyAuthorized(AccountError): +class AccountAlreadyAuthorized(AccountError, UserSideException): MESSAGE = "You are already authorized with {0} account." diff --git a/platformio/package/exception.py b/platformio/package/exception.py index d38c0e60..ba896fae 100644 --- a/platformio/package/exception.py +++ b/platformio/package/exception.py @@ -13,10 +13,10 @@ # limitations under the License. from platformio import util -from platformio.exception import PlatformioException, UserSideException +from platformio.exception import UserSideException -class PackageException(PlatformioException): +class PackageException(UserSideException): pass @@ -51,14 +51,14 @@ class MissingPackageManifestError(ManifestException): MESSAGE = "Could not find one of '{0}' manifest files in the package" -class UnknownPackageError(UserSideException): +class UnknownPackageError(PackageException): MESSAGE = ( "Could not find the package with '{0}' requirements for your system '%s'" % util.get_systype() ) -class NotGlobalLibDir(UserSideException): +class NotGlobalLibDir(PackageException): MESSAGE = ( "The `{0}` is not a PlatformIO project.\n\n" "To manage libraries in global storage `{1}`,\n" diff --git a/platformio/package/vcsclient.py b/platformio/package/vcsclient.py index c10235c7..67348391 100644 --- a/platformio/package/vcsclient.py +++ b/platformio/package/vcsclient.py @@ -18,7 +18,7 @@ import subprocess from urllib.parse import urlparse from platformio import proc -from platformio.package.exception import PlatformioException, UserSideException +from platformio.exception import UserSideException class VCSBaseException(UserSideException): @@ -70,7 +70,7 @@ class VCSClientBase: self.get_cmd_output(["--version"]) else: assert self.run_cmd(["--version"]) - except (AssertionError, OSError, PlatformioException) as exc: + except (AssertionError, OSError) as exc: raise VCSBaseException( "VCS: `%s` client is not installed in your system" % self.command ) from exc diff --git a/platformio/platform/exception.py b/platformio/platform/exception.py index f044d3b7..18ace0de 100644 --- a/platformio/platform/exception.py +++ b/platformio/platform/exception.py @@ -12,10 +12,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -from platformio.exception import PlatformioException +from platformio.exception import UserSideException -class PlatformException(PlatformioException): +class PlatformException(UserSideException): pass diff --git a/platformio/project/helpers.py b/platformio/project/helpers.py index 546cd670..cb004d23 100644 --- a/platformio/project/helpers.py +++ b/platformio/project/helpers.py @@ -180,7 +180,7 @@ def _load_build_metadata(project_dir, env_names, debug=False): ): raise result.exception if '"includes":' not in result.output: - raise exception.PlatformioException(result.output) + raise exception.UserSideException(result.output) return _get_cached_build_metadata(project_dir, env_names) diff --git a/platformio/telemetry.py b/platformio/telemetry.py index 0c8adc52..d288872a 100644 --- a/platformio/telemetry.py +++ b/platformio/telemetry.py @@ -17,6 +17,7 @@ import hashlib import os import queue import re +import sys import threading import time import traceback @@ -271,6 +272,7 @@ def log_exception(exc): "name": exc.__class__.__name__, "description": str(exc), "traceback": trace, + "cmd_args": sys.argv[1:], "is_fatal": is_fatal, } log_event("exception", params)