[clangd] Improve bad-RPC-payload error messages slightly

This commit is contained in:
Sam McCall 2020-09-24 01:51:29 +02:00
parent 23291e8ec7
commit 2bd5e3fb3c
1 changed files with 4 additions and 2 deletions

View File

@ -187,7 +187,8 @@ private:
T Result;
llvm::json::Path::Root Root;
if (!fromJSON(Raw, Result, Root)) {
elog("Failed to decode {0} {1}", PayloadName, PayloadKind);
elog("Failed to decode {0} {1}: {2}", PayloadName, PayloadKind,
Root.getError());
// Dump the relevant parts of the broken message.
std::string Context;
llvm::raw_string_ostream OS(Context);
@ -195,7 +196,8 @@ private:
vlog("{0}", OS.str());
// Report the error (e.g. to the client).
return llvm::make_error<LSPError>(
llvm::formatv("failed to decode {0} {1}", PayloadName, PayloadKind),
llvm::formatv("failed to decode {0} {1}: {2}", PayloadName,
PayloadKind, fmt_consume(Root.getError())),
ErrorCode::InvalidParams);
}
return std::move(Result);