diff --git a/CHANGELOG.md b/CHANGELOG.md index 64af28d09..0f49d5d98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ * Added option to disable `SimpleCache` key validation 1. [](#improved) * Improved `Utils::url()` to support query strings + * Display better exception message if Grav fails to initialize 1. [](#bugfix) * Fixed issue with uppercase extensions and fallback media URLs [#2133](https://github.com/getgrav/grav/issues/2133) * Fixed theme inheritance issue with `camel-case` that includes numbers [#2134](https://github.com/getgrav/grav/issues/2134) diff --git a/system/src/Grav/Common/Config/Setup.php b/system/src/Grav/Common/Config/Setup.php index e9180fea8..fba7fd103 100644 --- a/system/src/Grav/Common/Config/Setup.php +++ b/system/src/Grav/Common/Config/Setup.php @@ -262,18 +262,22 @@ class Setup extends Data ); } - if (!$locator->findResource('environment://config', true)) { - // If environment does not have its own directory, remove it from the lookup. - $this->set('streams.schemes.environment.prefixes', ['config' => []]); - $this->initializeLocator($locator); - } + try { + if (!$locator->findResource('environment://config', true)) { + // If environment does not have its own directory, remove it from the lookup. + $this->set('streams.schemes.environment.prefixes', ['config' => []]); + $this->initializeLocator($locator); + } - // Create security.yaml if it doesn't exist. - $filename = $locator->findResource('config://security.yaml', true, true); - $file = YamlFile::instance($filename); - if (!$file->exists()) { - $file->save(['salt' => Utils::generateRandomString(14)]); - $file->free(); + // Create security.yaml if it doesn't exist. + $filename = $locator->findResource('config://security.yaml', true, true); + $file = YamlFile::instance($filename); + if (!$file->exists()) { + $file->save(['salt' => Utils::generateRandomString(14)]); + $file->free(); + } + } catch (\RuntimeException $e) { + throw new \RuntimeException(sprintf('Grav failed to initialize: %s', $e->getMessage()), 500, $e); } } }