I am testing my error handling for mysqli by attempting to close an already a closed statement. Even though the second $stmt->close() is throwing an error, the catch is not being executed. I've researched other similar questions, but their solution, adding the mysqli_report call, doesn't help. I have the exact same construct in place for trapping other mysqli errors and it works in many instances. However in others I have this same issue - catch is just not invoked.
mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT | MYSQLI_REPORT_ALL);
// ... bunch of other code here, including successful connect and write to DB .... then...
// Close statement and connection
$stmt->close();
try {$stmt->close();}
catch (Exception $e) {
respond_forInsert (false, 400, "CAUGHT!");
exit
}
Error Message:
Fatalerror: UncaughtError: mysqli_stmtobjectisalreadyclosedinC: \Users\16305\LocalSites\easy-street-2\app\public\ee\api\lead\chat_session\insert_record.php: 178Stacktrace: #0C: \Users\16305\LocalSites\easy-street-2\app\public\ee\api\lead\chat_session\insert_record.php(178): mysqli_stmt->close()#1{
main
}throwninC: \Users\16305\LocalSites\easy-street-2\app\public\ee\api\lead\chat_session\insert_record.phponline178