Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error message for missing config file #709

Merged
merged 1 commit into from Nov 8, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 15 additions & 2 deletions lib/bootstrap.php
Expand Up @@ -24,6 +24,19 @@

use Volkszaehler\Util;

function fail($msg) {
if (preg_match('/\.json/', $_SERVER['REQUEST_URI'])) {
header('Content-type: application/json');
echo json_encode([
'version' => VZ_VERSION,
'exception' => array(
'message' => $msg
)
]);
}
die();
}

// enable strict error reporting
error_reporting(E_ALL | E_STRICT);

Expand All @@ -36,11 +49,11 @@
}

if (!file_exists(VZ_DIR . '/vendor/autoload.php')) {
die('Could not find autoloader. Check that dependencies have been installed via `composer install`.');
fail('Could not find autoloader. Check that dependencies have been installed via `composer install`.');
}

if (!file_exists(VZ_DIR . '/etc/volkszaehler.conf.php')) {
die('Could not find config file. Check that etc/volkszaehler.conf.php exists.');
fail('Could not find config file. Check that etc/volkszaehler.conf.php exists.');
}

require_once VZ_DIR . '/vendor/autoload.php';
Expand Down