Fix error handling and clean up controller.

Applies https://github.com/codeforamerica/ohana-web-search/pull/521
from upstream.