Skip to content

Commit d46cedd

Browse files
committed
Use non-generic exception
1 parent 2f37266 commit d46cedd

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/SimpleSAML/Utils/Config.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace SimpleSAML\Utils;
66

77
use SimpleSAML\Configuration;
8+
use SimpleSAML\Error;
89

910
/**
1011
* Utility class for SimpleSAMLphp configuration management and manipulation.
@@ -49,7 +50,10 @@ public function getSecretSalt(): string
4950
{
5051
$secretSalt = Configuration::getInstance()->getString('secretsalt');
5152
if ($secretSalt === 'defaultsecretsalt') {
52-
throw new \InvalidArgumentException('The "secretsalt" configuration option must be set to a secret value.');
53+
throw new Error\CriticalConfigurationError(
54+
'The "secretsalt" configuration option must be set to a secret value.',
55+
'config.php',
56+
);
5357
}
5458

5559
return $secretSalt;
@@ -74,7 +78,7 @@ public function getConfigDir(): string
7478

7579
if ($configDirEnv !== false) {
7680
if (!is_dir($configDirEnv)) {
77-
throw new \InvalidArgumentException(
81+
throw new Error\CriticalConfigurationError(
7882
sprintf(
7983
'Config directory specified by environment variable SIMPLESAMLPHP_CONFIG_DIR is not a ' .
8084
'directory. Given: "%s"',

tests/src/SimpleSAML/Utils/ConfigTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use InvalidArgumentException;
88
use PHPUnit\Framework\TestCase;
9+
use SimpleSAML\Error;
910
use SimpleSAML\Utils;
1011

1112
/**
@@ -89,7 +90,7 @@ public function testInvalidEnvVariableConfigDirThrowsException(): void
8990
$invalidDir = __DIR__ . '/e9826ad19cbc4f5bf20c0913ffcd2ce6';
9091
putenv('SIMPLESAMLPHP_CONFIG_DIR=' . $invalidDir);
9192

92-
$this->expectException(InvalidArgumentException::class);
93+
$this->expectException(Error\CriticalConfigurationError::class);
9394
$this->expectExceptionMessage(
9495
'Config directory specified by environment variable SIMPLESAMLPHP_CONFIG_DIR is not a directory. ' .
9596
'Given: "' . $invalidDir . '"'

0 commit comments

Comments
 (0)