From bd7d5bc67228a6264c50fecfbdf6ec5705617f1b Mon Sep 17 00:00:00 2001 From: NiiWiiCamo Date: Tue, 22 Aug 2023 13:22:29 +0200 Subject: [PATCH] changed error handling only throw stack trace if debug=true, otherwise only exit with short status message --- src/Handler.php | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/Handler.php b/src/Handler.php index ff537b9..8bf4e11 100644 --- a/src/Handler.php +++ b/src/Handler.php @@ -26,20 +26,32 @@ final class Handler $this->config = new Config($config); if (!$this->config->isValid()) { - throw new RuntimeException('configuration invalid'); + if ($this->config->isDebug()) { + throw new RuntimeException('configuration invalid'); + } else { + exit("configuration invalid\n"); + } } $this->payload = new Payload($payload); if (!$this->payload->isValid()) { - throw new RuntimeException('payload invalid'); + if ($this->config->isDebug()) { + throw new RuntimeException('payload invalid'); + } else { + exit("payload invalid\n"); + } } if ( $this->config->getUsername() !== $this->payload->getUser() || $this->config->getPassword() !== $this->payload->getPassword() ) { - throw new RuntimeException('credentials wrong'); + if ($this->config->isDebug()) { + throw new RuntimeException('credentials invalid'); + } else { + exit("credentials invalid\n"); + } } if (is_readable($this->config->getLogFile())) { @@ -152,8 +164,8 @@ final class Handler $this->doLog(sprintf('IPv6 for %s set to %s', $record->hostname . '.' . $this->payload->getHostname(), $this->payload->getIpv6())); $changes = true; } - - // update TXT Record if exists and content has changed + + // update TXT Record if exists and IP has changed if ('TXT' === $record->type && $this->payload->getTxt() && ( $this->payload->isForce()