Fixed error handling for PDF responses