How can PHP developers ensure that PDO throws exceptions for errors by default in PHP 8?

By default, PDO does not throw exceptions for errors in PHP 8, which can make error handling more challenging. To ensure that PDO throws exceptions for errors by default in PHP 8, developers can set the `PDO::ATTR_ERRMODE` attribute to `PDO::ERRMODE_EXCEPTION` when establishing the database connection. This will cause PDO to throw exceptions for errors, making it easier to handle and debug database-related issues.

$pdo = new PDO($dsn, $username, $password);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);