Catch a DB connection exception earlier [MAILPOET-966]

This commit is contained in:
stoletniy
2017-06-29 18:38:15 +03:00
committed by pavel-mailpoet
parent d3db755489
commit fb1a3a80ff
2 changed files with 22 additions and 6 deletions

View File

@ -31,7 +31,12 @@ class Initializer {
return;
}
$this->setupDB();
try {
$this->setupDB();
} catch(\Exception $e) {
$this->handleFailedInitialization($e);
return;
}
// activation function
register_activation_hook(
@ -232,7 +237,10 @@ class Initializer {
}
function handleFailedInitialization($message) {
Menu::addErrorPage();
// Check if we are able to add pages at this point
if (function_exists('wp_get_current_user')) {
Menu::addErrorPage();
}
return WPNotice::displayError($message);
}
}
}