Skip to content

hyera.exceptions

Exception hierarchy for hiera.

BackendError(*args, path=None)

Bases: HieraError, ValueError

A data file could not be read or parsed. .path names it.

Also a :class:ValueError.

Source code in src/hyera/exceptions.py
37
38
39
def __init__(self, *args: object, path: _ty.Optional[str] = None) -> None:
    super().__init__(*args)
    self.path: _ty.Optional[str] = path

BackendTimeoutError(*args, path=None)

Bases: BackendError, TimeoutError

An external program a backend or fact source runs (sops, facter) did not finish within its time limit and was killed along with its child processes.

Source code in src/hyera/exceptions.py
37
38
39
def __init__(self, *args: object, path: _ty.Optional[str] = None) -> None:
    super().__init__(*args)
    self.path: _ty.Optional[str] = path

ConfigError(*args, path=None, line=None)

Bases: HieraError, ValueError

The base hiera configuration (hiera.yaml) is missing or invalid.

Also a :class:ValueError.

line, when known, is the 1-based line in .path the problem was found at (e.g. a malformed hierarchy entry).

Parameters:

Name Type Description Default
args object

the positional arguments Exception itself takes (usually one message string).

()
path Optional[str]

the file this problem concerns, when known.

None
line Optional[int]

the 1-based line in path this problem concerns, when known.

None
Source code in src/hyera/exceptions.py
57
58
59
60
61
62
63
64
def __init__(
    self,
    *args: object,
    path: _ty.Optional[str] = None,
    line: _ty.Optional[int] = None,
) -> None:
    super().__init__(*args, path=path)
    self.line: _ty.Optional[int] = line

line = line instance-attribute

HieraError(*args, path=None)

Bases: Exception

Base class for all hiera errors.

path, when known, names the file the problem concerns.

Parameters:

Name Type Description Default
args object

the positional arguments Exception itself takes (usually one message string).

()
path Optional[str]

the file this problem concerns, when known.

None
Source code in src/hyera/exceptions.py
37
38
39
def __init__(self, *args: object, path: _ty.Optional[str] = None) -> None:
    super().__init__(*args)
    self.path: _ty.Optional[str] = path

path = path instance-attribute

HieraLookupError(*args, path=None)

Bases: HieraError

Puppet's LookupError: a failure while resolving a key.

Source code in src/hyera/exceptions.py
37
38
39
def __init__(self, *args: object, path: _ty.Optional[str] = None) -> None:
    super().__init__(*args)
    self.path: _ty.Optional[str] = path

InterpolationError(*args, path=None)

Bases: HieraLookupError, ValueError

A %{...} interpolation or function call could not be resolved.

Also a :class:ValueError.

Source code in src/hyera/exceptions.py
37
38
39
def __init__(self, *args: object, path: _ty.Optional[str] = None) -> None:
    super().__init__(*args)
    self.path: _ty.Optional[str] = path

KeyNotFoundError(name)

Bases: HieraLookupError, KeyError

Puppet's lookup() miss: no value was found for name.

Also a :class:KeyError, so an existing except KeyError keeps working. name is the key string, or list of key strings, that was tried; a list of one uses the singular message form. A name may also be a tuple key path: .name keeps it exactly as given, but the message text renders it as :func:~hyera._lookup.navigation.join_key's dotted form, same as the equivalent quoted string would read.

A bare tuple path is never passed here directly -- it would be misread as "several names" instead of one path with several segments. Every caller wraps it in a list first (even a list of one), the same way a single str name already is.

Parameters:

Name Type Description Default
name Union[str, Sequence[str]]

the key(s) that were tried.

required
Source code in src/hyera/exceptions.py
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
def __init__(self, name: _ty.Union[str, _ty.Sequence[str]]) -> None:
    # Deferred to avoid a module-load cycle (`_lookup.navigation` imports
    # `HieraLookupError` from this module).
    from ._lookup.navigation import join_key

    def _text(n):
        return join_key(n) if isinstance(n, tuple) else n

    if isinstance(name, (list, tuple)) and len(name) != 1:
        message = (
            "Function lookup() did not find a value for any of the "
            "names {!r}".format([_text(n) for n in name])
        )
    else:
        single = name[0] if isinstance(name, (list, tuple)) else name
        message = (
            "Function lookup() did not find a value for the name "
            "{!r}".format(_text(single))
        )
    super().__init__(message)
    self.name: _ty.Union[str, _ty.Sequence[str]] = name

name = name instance-attribute

__reduce__()

Source code in src/hyera/exceptions.py
163
164
165
166
def __reduce__(
    self,
) -> "_ty.Tuple[type, _ty.Tuple[_ty.Union[str, _ty.Sequence[str]]], _ty.Dict[str, _ty.Any]]":
    return (type(self), (self.name,), dict(self.__dict__))

__str__()

Source code in src/hyera/exceptions.py
160
161
def __str__(self) -> str:
    return Exception.__str__(self)

MergeError(*args, path=None)

Bases: HieraLookupError, ValueError

An unknown or invalid merge strategy was requested.

Also a :class:ValueError.

Source code in src/hyera/exceptions.py
37
38
39
def __init__(self, *args: object, path: _ty.Optional[str] = None) -> None:
    super().__init__(*args)
    self.path: _ty.Optional[str] = path