Add function for more detailed error reporting