Add more detailed error handler