libvintf: logging for listFiles error
Bug: 151696835
Test: atest .
Change-Id: I7846fa4687302b192ad19134aaefdbcce1ddf76c
diff --git a/FileSystem.cpp b/FileSystem.cpp
index 4a1043a..6b1f73a 100644
--- a/FileSystem.cpp
+++ b/FileSystem.cpp
@@ -64,6 +64,11 @@
out->push_back(dp->d_name);
}
}
+ if (errno != 0) {
+ if (error) {
+ *error = "Failed while reading directory " + path + ": " + strerror(errno);
+ }
+ }
return -errno;
}
diff --git a/VintfObject.cpp b/VintfObject.cpp
index a19d3e1..eca74d0 100644
--- a/VintfObject.cpp
+++ b/VintfObject.cpp
@@ -56,8 +56,9 @@
if (skipCache || !ptr->fetchedOnce) {
ptr->object = std::make_unique<T>();
std::string error;
- if (fetchAllInformation(ptr->object.get(), &error) != OK) {
- LOG(WARNING) << error;
+ status_t status = fetchAllInformation(ptr->object.get(), &error);
+ if (status != OK) {
+ LOG(WARNING) << status << ": " << error;
ptr->object = nullptr; // frees the old object
}
ptr->fetchedOnce = true;