Fix error handling with new config handling (#2666)

This commit is contained in:
Pascal Vizeli 2021-03-03 12:46:34 +01:00 committed by GitHub
parent a13a0b4770
commit 5fe2a815ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 12 deletions

View File

@ -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

View File

@ -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: