generate an exception for API error