1 """Blueprint errors."""
3 from __future__
import annotations
5 from collections.abc
import Iterable
8 import voluptuous
as vol
9 from voluptuous.humanize
import humanize_error
15 """Base exception for blueprint errors."""
17 def __init__(self, domain: str |
None, msg: str) ->
None:
18 """Initialize a blueprint exception."""
24 """Base exception for blueprint errors."""
27 self, domain: str |
None, blueprint_name: str |
None, msg: str
29 """Initialize blueprint exception."""
35 """When we failed to load the blueprint."""
37 def __init__(self, domain: str, blueprint_name: str, exc: Exception) ->
None:
38 """Initialize blueprint exception."""
39 super().
__init__(domain, blueprint_name, f
"Failed to load blueprint: {exc}")
43 """When we encountered an invalid blueprint."""
48 blueprint_name: str |
None,
50 msg_or_exc: str | vol.Invalid,
52 """Initialize an invalid blueprint error."""
53 if isinstance(msg_or_exc, vol.Invalid):
59 f
"Invalid blueprint: {msg_or_exc}",
65 """When we encountered invalid blueprint inputs."""
67 def __init__(self, domain: str, msg: str) ->
None:
68 """Initialize an invalid blueprint inputs error."""
71 f
"Invalid blueprint inputs: {msg}",
76 """When we miss an input."""
79 self, domain: str, blueprint_name: str, input_names: Iterable[str]
81 """Initialize blueprint exception."""
85 f
"Missing input {', '.join(sorted(input_names))}",
90 """Error when file already exists."""
92 def __init__(self, domain: str, blueprint_name: str) ->
None:
93 """Initialize blueprint exception."""
94 super().
__init__(domain, blueprint_name,
"Blueprint already exists")
98 """Error when a blueprint is in use."""
100 def __init__(self, domain: str, blueprint_name: str) ->
None:
101 """Initialize blueprint exception."""
102 super().
__init__(domain, blueprint_name,
"Blueprint in use")
None __init__(self, str|None domain, str msg)
None __init__(self, str domain, str blueprint_name)
None __init__(self, str|None domain, str|None blueprint_name, str msg)
None __init__(self, str domain, str blueprint_name, Exception exc)
None __init__(self, str domain, str blueprint_name)
None __init__(self, str|None domain, str|None blueprint_name, Any blueprint_data, str|vol.Invalid msg_or_exc)
str humanize_error(HomeAssistant hass, vol.Invalid validation_error, str domain, dict config, str|None link, int max_sub_error_length=MAX_VALIDATION_ERROR_ITEM_LENGTH)