2022-05-23 13:30:13 +00:00
|
|
|
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
2022-06-03 12:46:56 +00:00
|
|
|
from click.core import Context
|
|
|
|
|
|
|
|
|
2019-10-03 16:26:44 +00:00
|
|
|
class FatalError(RuntimeError):
|
|
|
|
"""
|
2019-11-18 16:34:33 +00:00
|
|
|
Wrapper class for runtime errors that aren't caused by bugs in idf.py or the build process.
|
2019-10-03 16:26:44 +00:00
|
|
|
"""
|
2021-02-01 10:40:03 +00:00
|
|
|
|
2022-06-03 12:46:56 +00:00
|
|
|
def __init__(self, message: str, ctx: Context=None):
|
2019-07-23 19:37:31 +00:00
|
|
|
super(RuntimeError, self).__init__(message)
|
|
|
|
# if context is defined, check for the cleanup tasks
|
2021-01-26 02:49:01 +00:00
|
|
|
if ctx is not None and 'cleanup' in ctx.meta:
|
2019-07-23 19:37:31 +00:00
|
|
|
# cleans up the environment before failure
|
2021-01-26 02:49:01 +00:00
|
|
|
ctx.meta['cleanup']()
|
2021-02-01 10:40:03 +00:00
|
|
|
|
|
|
|
|
|
|
|
class NoSerialPortFoundError(FatalError):
|
|
|
|
pass
|