Improved error generation