Repository navigation
Expand file tree
/
Copy patherrors.py
More file actions
43 lines (28 loc) · 1.4 KB
/
Copy patherrors.py
File metadata and controls
43 lines (28 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
"""Error hierarchy shared by the core and the plugins.
Merge of the two legacy hierarchies (`ansible_forge.errors` and
`helm_forge.errors`, cf. MIGRATION.md §5.1): a single implementation survives.
Every expected error derives from `ForgeError`: the CLI catches it and prints
`str(e)` with no Python traceback. An exception that does not derive from it is
a bug.
"""
from __future__ import annotations
class ForgeError(Exception):
"""An expected error, presentable to the user as it is."""
class SpecFileError(ForgeError):
"""The specification file is missing, unreadable or malformed."""
class SpecValidationError(ForgeError):
"""The specification content violates the assembled model."""
class PluginError(ForgeError):
"""A plugin is misdeclared, missing, or violates the hook contract."""
class RenderError(ForgeError):
"""The copier render failed."""
# Two classes were removed in phase 10, after checking that no code path raised
# them:
#
# * `ToolMissingError` — `forge.validate.tools.missing_message()` composes the
# same message, and the core reports a missing tool through a validation
# report, never through an exception: one skipped command does not interrupt
# the others.
# * `ValidationFailed` — `ValidationResult.ok` carries the verdict and the CLI
# derives its exit code from it. Raising would have lost the report, which is
# precisely what the user wants to read.