What potential pitfalls should be considered when implementing a custom error handling mechanism in PHP?

When implementing a custom error handling mechanism in PHP, it's important to consider potential pitfalls such as introducing security vulnerabilities if sensitive information is exposed in error messages, creating overly complex error handling logic that may be difficult to maintain, and potentially impacting performance if the custom error handling is not optimized.

// Custom error handling function
function customErrorHandler($errno, $errstr, $errfile, $errline) {
    // Log the error
    error_log("Error: [$errno] $errstr in $errfile on line $errline", 0);

    // Display a user-friendly error message
    echo "An error occurred. Please try again later.";

    // Optionally, you can also send an email notification to the developer
    // mail("developer@example.com", "Error occurred", "Error: [$errno] $errstr in $errfile on line $errline");
}

// Set the custom error handler
set_error_handler("customErrorHandler");