if conversion to JSON fails, at least send a JSON output of the error instead of hanging the client