From 26d76b75c71b75600eeff6addc36972057cf5542 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 30 Oct 2018 22:26:01 -0700 Subject: [PATCH] Report InvalidParams for serialization error --- src/message_handler.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/message_handler.cc b/src/message_handler.cc index b85bdd50..427dac75 100644 --- a/src/message_handler.cc +++ b/src/message_handler.cc @@ -22,9 +22,10 @@ limitations under the License. #include "query_utils.hh" #include "serializers/json.hh" -using namespace clang; - #include +#include + +using namespace clang; MAKE_HASHABLE(ccls::SymbolIdx, t.usr, t.kind); @@ -204,8 +205,16 @@ void MessageHandler::Run(InMessage &msg) { if (it != method2request.end()) { try { it->second(reader, reply); + } catch (std::invalid_argument &ex) { + lsResponseError err; + err.code = lsErrorCodes::InvalidParams; + err.message = "invalid params of " + msg.method + ": " + ex.what(); + reply.Error(err); } catch (...) { - LOG_S(ERROR) << "failed to process request " << msg.method; + lsResponseError err; + err.code = lsErrorCodes::InternalError; + err.message = "failed to process " + msg.method; + reply.Error(err); } } else { lsResponseError err;