errors.py 649 B

1234567891011121314151617181920
  1. # SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
  2. # SPDX-License-Identifier: Apache-2.0
  3. from click.core import Context
  4. class FatalError(RuntimeError):
  5. """
  6. Wrapper class for runtime errors that aren't caused by bugs in idf.py or the build process.
  7. """
  8. def __init__(self, message: str, ctx: Context=None):
  9. super(RuntimeError, self).__init__(message)
  10. # if context is defined, check for the cleanup tasks
  11. if ctx is not None and 'cleanup' in ctx.meta:
  12. # cleans up the environment before failure
  13. ctx.meta['cleanup']()
  14. class NoSerialPortFoundError(FatalError):
  15. pass