[PATCH] D85502: [clangd] Add more error details on the remote index server side

Kirill Bobyrev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 7 00:02:06 PDT 2020


kbobyrev created this revision.
kbobyrev added a reviewer: kadircet.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous.
Herald added a project: clang.
kbobyrev requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D85502

Files:
  clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp


Index: clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
===================================================================
--- clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
+++ clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp
@@ -23,6 +23,7 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/FormatVariadic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/StringSaver.h"
 
@@ -303,7 +304,8 @@
   if (RelativePath.empty())
     return makeStringError("Empty relative path.");
   if (llvm::sys::path::is_absolute(RelativePath))
-    return makeStringError("RelativePath is absolute.");
+    return makeStringError(
+        llvm::formatv("RelativePath {0} is absolute.", RelativePath).str());
   llvm::SmallString<256> FullPath = llvm::StringRef(*LocalIndexRoot);
   llvm::sys::path::append(FullPath, RelativePath);
   auto Result = URI::createFile(FullPath);
@@ -316,10 +318,16 @@
   if (!ParsedURI)
     return ParsedURI.takeError();
   if (ParsedURI->scheme() != "file")
-    return makeStringError("Can not use URI schemes other than file.");
+    return makeStringError(
+        llvm::formatv("Can not use URI schemes other than file, given: {0}.",
+                      URI)
+            .str());
   llvm::SmallString<256> Result = ParsedURI->body();
   if (!llvm::sys::path::replace_path_prefix(Result, *RemoteIndexRoot, ""))
-    return makeStringError("File path doesn't start with RemoteIndexRoot.");
+    return makeStringError(
+        llvm::formatv("File path {0} doesn't start with RemoteIndexRoot.",
+                      Result.str())
+            .str());
   // Make sure the result has UNIX slashes.
   return llvm::sys::path::convert_to_slash(Result,
                                            llvm::sys::path::Style::posix);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85502.283823.patch
Type: text/x-patch
Size: 1890 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200807/d8521847/attachment.bin>


More information about the cfe-commits mailing list