From 0eceff007c42b143613b3ca87a4d20b451726439 Mon Sep 17 00:00:00 2001 From: netkas Date: Fri, 21 Mar 2025 15:12:31 -0400 Subject: [PATCH] Refactor exception handling in Configuration class to include error codes --- CHANGELOG.md | 1 + src/ConfigLib/Configuration.php | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6665422..ea756d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This update introduces minor changes ### Changed - Disabled tty mode for the main execution points to prevent issues with docker environments + - Refactor exception handling in Configuration class to include error codes ## [1.1.7] - 2025-03-14 diff --git a/src/ConfigLib/Configuration.php b/src/ConfigLib/Configuration.php index dddb5b1..8a83a59 100644 --- a/src/ConfigLib/Configuration.php +++ b/src/ConfigLib/Configuration.php @@ -172,7 +172,7 @@ catch(Exception $e) { $this->logger->error(sprintf('Unable to load configuration "%s", %s', $this->name, $e->getMessage()), $e); - throw new RuntimeException(sprintf('Unable to load configuration "%s"', $this->name), $e); + throw new RuntimeException(sprintf('Unable to load configuration "%s"', $this->name), $e->getCode(), $e); } } else @@ -359,7 +359,7 @@ } catch (Exception $e) { - throw new RuntimeException('Unable to write configuration file', $e); + throw new RuntimeException('Unable to write configuration file', $e->getCode(), $e); } $this->modified = false; @@ -408,7 +408,7 @@ } catch (Exception $e) { - throw new RuntimeException('Unable to read configuration file', $e); + throw new RuntimeException('Unable to read configuration file', $e->getCode(), $e); } $prefix = 'CONFIGLIB_' . strtoupper($this->name) . '_';