Ensure #route_setting is available before calling it

Merged Rémy Coutable requested to merge sh-fix-api-exception-handling into master

What does this MR do?

This is another approach to gitlab-org/gitlab-ce!14178.

Does this MR meet the acceptance criteria?