How can error handling be improved in the provided PHP script to provide more detailed error messages for debugging?

The issue with the current error handling in the provided PHP script is that it only displays generic error messages, which makes debugging difficult. To improve error handling and provide more detailed error messages for debugging, you can use try-catch blocks to catch specific exceptions and display custom error messages.

try {
    // Code that may throw an exception
    $result = someFunction();
} catch (Exception $e) {
    echo 'An error occurred: ' . $e->getMessage();
}