When encountering SQL errors in PHP scripts, what steps can be taken to ensure sensitive information, such as passwords, is not exposed in error messages?

When encountering SQL errors in PHP scripts, it is crucial to ensure that sensitive information, such as passwords, is not exposed in error messages. One way to achieve this is by setting the `PDO::ATTR_ERRMODE` attribute to `PDO::ERRMODE_EXCEPTION`, which will throw exceptions instead of displaying error messages containing sensitive information.

try {
    $pdo = new PDO($dsn, $username, $password);
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    
    // Your SQL queries here
    
} catch(PDOException $e) {
    echo "An error occurred. Please try again later.";
}