Created an action for rendering errors as JSON
Added a filter to handle future non-ajax requests to the api