Skip to content

Commit

Permalink
Report InvalidParams for serialization error
Browse files Browse the repository at this point in the history
  • Loading branch information
MaskRay committed Dec 11, 2018
1 parent 93371b9 commit f29d03e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/message_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ limitations under the License.
#include "query_utils.hh"
#include "serializers/json.hh"

using namespace clang;

#include <algorithm>
#include <stdexcept>

using namespace clang;

MAKE_HASHABLE(ccls::SymbolIdx, t.usr, t.kind);

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit f29d03e

Please sign in to comment.