mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-15 13:16:29 +00:00
Fix error handling with new config handling (#2666)
This commit is contained in:
parent
a13a0b4770
commit
5fe2a815ad
@ -275,27 +275,27 @@ class AppArmorInvalidError(AppArmorError):
|
||||
"""AppArmor profile validate error."""
|
||||
|
||||
|
||||
# util/common
|
||||
|
||||
|
||||
class ConfigurationFileError(HassioError):
|
||||
"""Invalid JSON or YAML file."""
|
||||
|
||||
|
||||
# util/json
|
||||
|
||||
|
||||
class JsonFileError(HassioError):
|
||||
class JsonFileError(ConfigurationFileError):
|
||||
"""Invalid JSON file."""
|
||||
|
||||
|
||||
# util/yaml
|
||||
|
||||
|
||||
class YamlFileError(HassioError):
|
||||
class YamlFileError(ConfigurationFileError):
|
||||
"""Invalid YAML file."""
|
||||
|
||||
|
||||
# util/common
|
||||
|
||||
|
||||
class ConfigurationFileError(JsonFileError, YamlFileError):
|
||||
"""Invalid JSON or YAML file."""
|
||||
|
||||
|
||||
# util/pwned
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@ from typing import Any, Dict, List, Optional
|
||||
import voluptuous as vol
|
||||
from voluptuous.humanize import humanize_error
|
||||
|
||||
from ..exceptions import ConfigurationFileError, HassioError
|
||||
from ..exceptions import ConfigurationFileError
|
||||
from .json import read_json_file, write_json_file
|
||||
from .yaml import read_yaml_file, write_yaml_file
|
||||
|
||||
@ -33,7 +33,7 @@ def read_json_or_yaml_file(path: Path) -> dict:
|
||||
if path.suffix in [".yaml", ".yml"]:
|
||||
return read_yaml_file(path)
|
||||
|
||||
raise HassioError(f"{path} is not JSON or YAML")
|
||||
raise ConfigurationFileError(f"{path} is not JSON or YAML")
|
||||
|
||||
|
||||
def write_json_or_yaml_file(path: Path, data: dict) -> None:
|
||||
@ -44,7 +44,7 @@ def write_json_or_yaml_file(path: Path, data: dict) -> None:
|
||||
if path.suffix in [".yaml", ".yml"]:
|
||||
return write_yaml_file(path, data)
|
||||
|
||||
raise HassioError(f"{path} is not JSON or YAML")
|
||||
raise ConfigurationFileError(f"{path} is not JSON or YAML")
|
||||
|
||||
|
||||
class FileConfiguration:
|
||||
|
Loading…
x
Reference in New Issue
Block a user