refactor: Handle database exceptions properly (#8720)

Display the errors to the user
Hide the query, unless APP_DEBUG=true in .env
Much easier to display output for other exceptions now, just need to add a render() function to them
This commit is contained in:
Tony Murray
2018-05-15 15:07:29 -05:00
committed by Neil Lathwood
parent e22642c73f
commit 43b54fcf39
5 changed files with 57 additions and 18 deletions

View File

@@ -78,7 +78,6 @@ function dbConnect($db_host = null, $db_user = '', $db_pass = '', $db_name = '',
}
$database_link = @mysqli_connect('p:' . $db_host, $db_user, $db_pass, null, $db_port, $db_socket);
mysqli_options($database_link, MYSQLI_OPT_LOCAL_INFILE, false);
if ($database_link === false) {
$error = mysqli_connect_error();
if ($error == 'No such file or directory') {
@@ -87,6 +86,8 @@ function dbConnect($db_host = null, $db_user = '', $db_pass = '', $db_name = '',
throw new DatabaseConnectException($error);
}
mysqli_options($database_link, MYSQLI_OPT_LOCAL_INFILE, false);
$database_db = mysqli_select_db($database_link, $db_name);
if (!$database_db) {
$db_create_sql = "CREATE DATABASE $db_name CHARACTER SET utf8 COLLATE utf8_unicode_ci";