Better API error logging