Refactor exception handling in Configuration class to include error codes

This commit is contained in:
netkas 2025-03-21 15:12:31 -04:00
parent 6acde50ec1
commit 0eceff007c
Signed by: netkas
GPG key ID: 4D8629441B76E4CC
2 changed files with 4 additions and 3 deletions

View file

@ -11,6 +11,7 @@ This update introduces minor changes
### Changed ### Changed
- Disabled tty mode for the main execution points to prevent issues with docker environments - 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 ## [1.1.7] - 2025-03-14

View file

@ -172,7 +172,7 @@
catch(Exception $e) catch(Exception $e)
{ {
$this->logger->error(sprintf('Unable to load configuration "%s", %s', $this->name, $e->getMessage()), $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 else
@ -359,7 +359,7 @@
} }
catch (Exception $e) 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; $this->modified = false;
@ -408,7 +408,7 @@
} }
catch (Exception $e) 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) . '_'; $prefix = 'CONFIGLIB_' . strtoupper($this->name) . '_';