Files
platformio-core/platformio/exception.py

270 lines
7.1 KiB
Python
Raw Normal View History

# Copyright (c) 2014-present PlatformIO <contact@platformio.org>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class PlatformioException(Exception):
MESSAGE = None
def __str__(self): # pragma: no cover
if self.MESSAGE:
return self.MESSAGE.format(*self.args)
2017-04-15 16:36:59 +03:00
return Exception.__str__(self)
class ReturnErrorCode(PlatformioException):
MESSAGE = "{0}"
2015-09-05 22:58:42 +03:00
class MinitermException(PlatformioException):
pass
2017-07-03 13:35:39 +03:00
class UserSideException(PlatformioException):
pass
2015-02-15 23:39:02 +02:00
class AbortedByUser(PlatformioException):
MESSAGE = "Aborted by user"
class UnknownPlatform(PlatformioException):
MESSAGE = "Unknown development platform '{0}'"
class IncompatiblePlatform(PlatformioException):
MESSAGE = "Development platform '{0}' is not compatible with PIO Core v{1}"
class PlatformNotInstalledYet(PlatformioException):
2017-12-23 19:48:16 +02:00
MESSAGE = ("The platform '{0}' has not been installed yet. "
"Use `platformio platform install {0}` command")
2015-12-08 18:42:50 +02:00
class BoardNotDefined(PlatformioException):
2017-12-23 19:48:16 +02:00
MESSAGE = (
"You need to specify board ID using `-b` or `--board` option. "
"Supported boards list is available via `platformio boards` command")
2015-12-08 18:42:50 +02:00
class UnknownBoard(PlatformioException):
MESSAGE = "Unknown board ID '{0}'"
class InvalidBoardManifest(PlatformioException):
MESSAGE = "Invalid board JSON manifest '{0}'"
class UnknownFramework(PlatformioException):
MESSAGE = "Unknown framework '{0}'"
class UnknownPackage(PlatformioException):
MESSAGE = "Detected unknown package '{0}'"
class MissingPackageManifest(PlatformioException):
MESSAGE = "Could not find one of '{0}' manifest files in the package"
class UndefinedPackageVersion(PlatformioException):
2017-12-23 19:48:16 +02:00
MESSAGE = ("Could not find a version that satisfies the requirement '{0}'"
" for your system '{1}'")
class PackageInstallError(PlatformioException):
2018-01-13 01:19:41 +02:00
MESSAGE = ("Could not install '{0}' with version requirements '{1}' "
"for your system '{2}'.\n\n"
"Please try this solution -> http://bit.ly/faq-package-manager")
class ExtractArchiveItemError(PlatformioException):
MESSAGE = (
"Could not extract `{0}` to `{1}`. Try to disable antivirus "
"tool or check this solution -> http://bit.ly/faq-package-manager")
class FDUnrecognizedStatusCode(PlatformioException):
MESSAGE = "Got an unrecognized status code '{0}' when downloaded {1}"
class FDSizeMismatch(PlatformioException):
2017-12-23 19:48:16 +02:00
MESSAGE = ("The size ({0:d} bytes) of downloaded file '{1}' "
"is not equal to remote size ({2:d} bytes)")
class FDSHASumMismatch(PlatformioException):
2017-12-23 19:48:16 +02:00
MESSAGE = ("The 'sha1' sum '{0}' of downloaded file '{1}' "
"is not equal to remote '{2}'")
2016-08-01 00:14:22 +03:00
class NotPlatformIOProject(PlatformioException):
2017-12-23 19:48:16 +02:00
MESSAGE = (
"Not a PlatformIO project. `platformio.ini` file has not been "
"found in current working directory ({0}). To initialize new project "
"please use `platformio init` command")
class UndefinedEnvPlatform(PlatformioException):
MESSAGE = "Please specify platform for '{0}' environment"
class UnsupportedArchiveType(PlatformioException):
MESSAGE = "Can not unpack file '{0}'"
2014-12-04 23:17:45 +02:00
class ProjectEnvsNotAvailable(PlatformioException):
MESSAGE = "Please setup environments in `platformio.ini` file"
class UnknownEnvNames(PlatformioException):
MESSAGE = "Unknown environment names '{0}'. Valid names are '{1}'"
class GetSerialPortsError(PlatformioException):
MESSAGE = "No implementation for your platform ('{0}') available"
class GetLatestVersionError(PlatformioException):
MESSAGE = "Can not retrieve the latest PlatformIO version"
2014-09-03 23:03:49 +03:00
class APIRequestError(PlatformioException):
MESSAGE = "[API] {0}"
2016-09-19 15:10:28 +03:00
class InternetIsOffline(PlatformioException):
2017-12-23 19:48:16 +02:00
MESSAGE = (
"You are not connected to the Internet.\n"
"If you build a project first time, we need Internet connection "
"to install all dependencies and toolchain.")
2016-09-19 15:10:28 +03:00
class LibNotFound(PlatformioException):
2017-12-23 19:48:16 +02:00
MESSAGE = ("Library `{0}` has not been found in PlatformIO Registry.\n"
"You can ignore this message, if `{0}` is a built-in library "
"(included in framework, SDK). E.g., SPI, Wire, etc.")
2014-11-22 23:55:17 +02:00
2016-08-26 12:30:37 +03:00
class NotGlobalLibDir(PlatformioException):
2017-12-23 19:48:16 +02:00
MESSAGE = (
"The `{0}` is not a PlatformIO project.\n\n"
"To manage libraries in global storage `{1}`,\n"
"please use `platformio lib --global {2}` or specify custom storage "
"`platformio lib --storage-dir /path/to/storage/ {2}`.\n"
"Check `platformio lib --help` for details.")
2016-08-26 12:30:37 +03:00
class InvalidLibConfURL(PlatformioException):
MESSAGE = "Invalid library config URL '{0}'"
2018-06-20 16:32:38 +03:00
class InvalidProjectConf(PlatformioException):
MESSAGE = "Invalid `platformio.ini`, project configuration file: '{0}'"
2014-11-22 23:55:17 +02:00
class BuildScriptNotFound(PlatformioException):
MESSAGE = "Invalid path '{0}' to build script"
2014-11-29 22:39:44 +02:00
class InvalidSettingName(PlatformioException):
MESSAGE = "Invalid setting with the name '{0}'"
2014-11-29 22:39:44 +02:00
class InvalidSettingValue(PlatformioException):
MESSAGE = "Invalid value '{0}' for the setting '{1}'"
2018-04-15 06:08:29 +03:00
class InvalidJSONFile(PlatformioException):
MESSAGE = "Could not load broken JSON: {0}"
class CIBuildEnvsEmpty(PlatformioException):
2017-12-23 19:48:16 +02:00
MESSAGE = ("Can't find PlatformIO build environments.\n"
"Please specify `--board` or path to `platformio.ini` with "
"predefined environments using `--project-conf` option")
2015-11-26 22:02:59 +02:00
class UpgradeError(PlatformioException):
MESSAGE = """{0}
2015-12-07 22:44:31 +02:00
* Upgrade using `pip install -U platformio`
2015-11-26 22:02:59 +02:00
* Try different installation/upgrading steps:
2016-12-05 21:25:10 +02:00
http://docs.platformio.org/page/installation.html
2015-11-26 22:02:59 +02:00
"""
2015-09-10 20:23:37 +03:00
class HomeDirPermissionsError(PlatformioException):
2017-12-23 19:48:16 +02:00
MESSAGE = (
"The directory `{0}` or its parent directory is not owned by the "
"current user and PlatformIO can not store configuration data.\n"
"Please check the permissions and owner of that directory.\n"
"Otherwise, please remove manually `{0}` directory and PlatformIO "
"will create new from the current user.")
2015-09-10 20:23:37 +03:00
class CygwinEnvDetected(PlatformioException):
2017-12-23 19:48:16 +02:00
MESSAGE = ("PlatformIO does not work within Cygwin environment. "
"Use native Terminal instead.")
class DebugSupportError(PlatformioException):
MESSAGE = ("Currently, PlatformIO does not support debugging for `{0}`.\n"
2018-06-28 23:57:16 +03:00
"Please contact support@pioplus.com or visit "
"< http://docs.platformio.org/page/plus/debugging.html >")
class DebugInvalidOptions(PlatformioException):
pass