diff --git a/src/message_handler.cc b/src/message_handler.cc index 7abf842f..451fc525 100644 --- a/src/message_handler.cc +++ b/src/message_handler.cc @@ -10,9 +10,10 @@ #include "query_utils.hh" #include "serializers/json.hh" -using namespace clang; - #include +#include + +using namespace clang; MAKE_HASHABLE(ccls::SymbolIdx, t.usr, t.kind); @@ -192,8 +193,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;