| 1 |
from __future__ import annotations |
| 2 |
|
| 3 |
|
| 4 |
TYPE_CHECKING = False |
| 5 |
|
| 6 |
if TYPE_CHECKING: |
| 7 |
import subprocess |
| 8 |
import types |
| 9 |
|
| 10 |
|
| 11 |
class BuildException(Exception): |
| 12 |
""" |
| 13 |
Exception raised by ``build`` when a build cannot proceed. |
| 14 |
""" |
| 15 |
|
| 16 |
|
| 17 |
class BuildBackendException(Exception): |
| 18 |
""" |
| 19 |
Exception raised when a backend operation fails. |
| 20 |
""" |
| 21 |
|
| 22 |
def __init__( |
| 23 |
self, |
| 24 |
exception: Exception, |
| 25 |
description: str | None = None, |
| 26 |
exc_info: tuple[type[BaseException], BaseException, types.TracebackType] | tuple[None, None, None] = ( |
| 27 |
None, |
| 28 |
None, |
| 29 |
None, |
| 30 |
), |
| 31 |
) -> None: |
| 32 |
super().__init__() |
| 33 |
self.exception = exception |
| 34 |
self.exc_info = exc_info |
| 35 |
self._description = description |
| 36 |
|
| 37 |
def __str__(self) -> str: |
| 38 |
if self._description: |
| 39 |
return self._description |
| 40 |
return f'Backend operation failed: {self.exception!r}' |
| 41 |
|
| 42 |
|
| 43 |
class BuildSystemTableValidationError(BuildException): |
| 44 |
""" |
| 45 |
Exception raised when the ``[build-system]`` table in pyproject.toml is invalid. |
| 46 |
""" |
| 47 |
|
| 48 |
def __str__(self) -> str: |
| 49 |
return f'Failed to validate `build-system` in pyproject.toml: {self.args[0]}' |
| 50 |
|
| 51 |
|
| 52 |
class FailedProcessError(Exception): |
| 53 |
""" |
| 54 |
Exception raised when a setup or preparation operation fails. |
| 55 |
""" |
| 56 |
|
| 57 |
def __init__(self, exception: subprocess.CalledProcessError, description: str) -> None: |
| 58 |
super().__init__() |
| 59 |
self.exception = exception |
| 60 |
self._description = description |
| 61 |
|
| 62 |
def __str__(self) -> str: |
| 63 |
return self._description |
| 64 |
|
| 65 |
|
| 66 |
class TypoWarning(Warning): |
| 67 |
""" |
| 68 |
Warning raised when a possible typo is found. |
| 69 |
""" |