function display_db_exception($pdo_exception) { global $debug_mode; if (isset($_SESSION['user'])) { $usr_id = $_SESSION['user']->usr_id; } else { $usr_id = ""; } $stack = generateCallTrace(); if (strlen($stack) > 1000) { $stack = substr($stack, 0, 1000); } log_pdo_exception($pdo_exception, $usr_id, $stack, ''); if ($debug_mode === true) { display_error('A database error has occurred.<br><br>' . 'Message:<br>' . $pdo_exception->getMessage() . '<br><br>' . 'Stack:<br>' . nl2br($stack) . '<br><br>' . 'PDO Code:<br>' . $pdo_exception->getCode() . '<br><br>' . 'PDO File:<br>' . $pdo_exception->getFile() . '<br><br>' . 'PDO Line:<br>' . $pdo_exception->getLine() . '<br><br>'); } else { display_error('A database error has occurred. Please try again.'); } exit; }
function display_db_exception_v2($pdo_exception) { global $debug_mode; if (isset($_SESSION['user'])) { $usr_id = $_SESSION['user']->usr_id; } else { $usr_id = ""; } $stack = generateCallTrace(); if (strlen($stack) > 1000) { $stack = substr($stack, 0, 1000); } log_pdo_exception($pdo_exception, $usr_id, $stack, ''); display_error('You have tried to delete a format which is being used by a workshop. Please remove the format from the workshops before deleting the format.'); exit; }