Improved error handling when no data is provided