From 800fb683f803b7653f7498c12c1d3a74d7543403 Mon Sep 17 00:00:00 2001 From: Vighnesh Kadam <50268642+vighnesh-kadam@users.noreply.github.com> Date: Sun, 3 Oct 2021 22:03:30 +0530 Subject: [PATCH] Use new format for logging exceptions - plugins/dns.py (#3191) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Joakim Sørensen --- supervisor/plugins/dns.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/supervisor/plugins/dns.py b/supervisor/plugins/dns.py index f9a024c45..ebaf1ac39 100644 --- a/supervisor/plugins/dns.py +++ b/supervisor/plugins/dns.py @@ -178,8 +178,7 @@ class PluginDns(PluginBase): try: await self.instance.update(version, image=self.sys_updater.image_dns) except DockerError as err: - _LOGGER.error("CoreDNS update failed") - raise CoreDNSUpdateError() from err + raise CoreDNSUpdateError("CoreDNS update failed", _LOGGER.error) from err else: self.version = version self.image = self.sys_updater.image_dns @@ -199,8 +198,7 @@ class PluginDns(PluginBase): try: await self.instance.restart() except DockerError as err: - _LOGGER.error("Can't start CoreDNS plugin") - raise CoreDNSError() from err + raise CoreDNSError("Can't start CoreDNS plugin", _LOGGER.error) from err async def start(self) -> None: """Run CoreDNS.""" @@ -211,8 +209,7 @@ class PluginDns(PluginBase): try: await self.instance.run() except DockerError as err: - _LOGGER.error("Can't start CoreDNS plugin") - raise CoreDNSError() from err + raise CoreDNSError("Can't start CoreDNS plugin", _LOGGER.error) from err async def stop(self) -> None: """Stop CoreDNS.""" @@ -220,8 +217,7 @@ class PluginDns(PluginBase): try: await self.instance.stop() except DockerError as err: - _LOGGER.error("Can't stop CoreDNS plugin") - raise CoreDNSError() from err + raise CoreDNSError("Can't stop CoreDNS plugin", _LOGGER.error) from err async def reset(self) -> None: """Reset DNS and hosts.""" @@ -288,8 +284,9 @@ class PluginDns(PluginBase): }, ) except ConfigurationFileError as err: - _LOGGER.error("Can't update coredns config: %s", err) - raise CoreDNSError() from err + raise CoreDNSError( + f"Can't update coredns config: {err}", _LOGGER.error + ) from err def _init_hosts(self) -> None: """Import hosts entry.""" @@ -314,8 +311,7 @@ class PluginDns(PluginBase): try: self.hosts.write_text(data, encoding="utf-8") except OSError as err: - _LOGGER.error("Can't update hosts: %s", err) - raise CoreDNSError() from err + raise CoreDNSError(f"Can't update hosts: {err}", _LOGGER.error) from err def add_host(self, ipv4: IPv4Address, names: list[str], write: bool = True) -> None: """Add a new host entry."""