Files
esp-idf/tools/idf_py_actions/errors.py
Marek Fiala 8c08c75f48 feat(tools): adopt esp-pylib for idf.py logging and errors
Migrate idf.py and its actions to the shared esp-pylib library:
- add esp-pylib (and esp-pylib[ide]) to the core/ide requirements
- base FatalError on esp_pylib.errors.FatalError, keeping the idf.py ctx cleanup
- replace the local raw-ANSI helpers (red_print/yellow_print/print_warning/
  color_print) with esp_pylib.logger.log (warn/err/note/hint) across the
  idf.py actions
- install esp_pylib exception reporting at the idf.py entry point and silence
  the logger during shell completion
- update affected tests for the new prefixes/line wrapping
- add normalize_output() helper and unify terminal env in conftest to handle
  Rich line-wrapping in CI assertions

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-15 20:19:07 +08:00

25 lines
837 B
Python

# SPDX-FileCopyrightText: 2022-2026 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
from esp_pylib.errors import FatalError as PylibFatalError
from rich_click import Context
class FatalError(PylibFatalError):
"""
Wrapper class for runtime errors that aren't caused by bugs in idf.py or the build process.
Extends the shared ``esp_pylib.errors.FatalError`` (a ``RuntimeError``) while keeping the
idf.py-specific context cleanup hook.
"""
def __init__(self, message: str, ctx: Context = None):
super().__init__(message)
# if context is defined, check for the cleanup tasks
if ctx is not None and 'cleanup' in ctx.meta:
# cleans up the environment before failure
ctx.meta['cleanup']()
class NoSerialPortFoundError(FatalError):
pass