Error handling

Much better handling of errors, including showing them on the HTML view and giving a valid JSON response on the JSON view.