Improved error handling in the frontend