What could be the reason for not receiving proper error messages through Exception or Warning in PDO, but instead getting a 500 error?

The reason for not receiving proper error messages through Exception or Warning in PDO could be due to the server configuration settings, such as error reporting being turned off or set to not display errors. To solve this issue, you can enable error reporting in your PHP script using the `error_reporting` and `ini_set` functions.

<?php
// Enable error reporting
error_reporting(E_ALL);
ini_set('display_errors', 1);

// Your PDO code here
try {
    $pdo = new PDO('mysql:host=localhost;dbname=test', 'username', 'password');
} catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
}
?>