Error controller to handle HTTP errors.

Fixes #257 and #310.
nit: indent