Raise exception on API error.