forked from qt-creator/qt-creator
ProjectExplorer: Improve error reporting
Previously anytime a FilePath operation tried to access a device that does not have a DeviceFileAccess an error message would be thrown. This patch makes it possible to differentiate between the device not being found, and the device just not having a DeviceFileAccess interface. Also the error message in DeviceFileAccess::exists() was removed as its not an error to ask if something exists even if it does not. Change-Id: Ib8c2e08132159d0d97bcd049b59436eb17bdbacd Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -120,7 +120,6 @@ bool DeviceFileAccess::createDirectory(const FilePath &filePath) const
|
|||||||
bool DeviceFileAccess::exists(const FilePath &filePath) const
|
bool DeviceFileAccess::exists(const FilePath &filePath) const
|
||||||
{
|
{
|
||||||
Q_UNUSED(filePath)
|
Q_UNUSED(filePath)
|
||||||
QTC_CHECK(false);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -939,9 +939,9 @@ DeviceFileAccess *FilePath::fileAccess() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
static DeviceFileAccess dummy;
|
static DeviceFileAccess dummy;
|
||||||
DeviceFileAccess *access = s_deviceHooks.fileAccess(*this);
|
const expected_str<DeviceFileAccess *> access = s_deviceHooks.fileAccess(*this);
|
||||||
QTC_ASSERT(access, qDebug() << toString(); return &dummy);
|
QTC_ASSERT_EXPECTED(access, return &dummy);
|
||||||
return access;
|
return *access ? *access : &dummy;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@@ -269,7 +269,7 @@ class QTCREATOR_UTILS_EXPORT DeviceFileHooks
|
|||||||
public:
|
public:
|
||||||
static DeviceFileHooks &instance();
|
static DeviceFileHooks &instance();
|
||||||
|
|
||||||
std::function<DeviceFileAccess *(const FilePath &)> fileAccess;
|
std::function<expected_str<DeviceFileAccess *>(const FilePath &)> fileAccess;
|
||||||
std::function<QString(const FilePath &)> deviceDisplayName;
|
std::function<QString(const FilePath &)> deviceDisplayName;
|
||||||
std::function<bool(const FilePath &, const FilePath &)> ensureReachable;
|
std::function<bool(const FilePath &, const FilePath &)> ensureReachable;
|
||||||
std::function<Environment(const FilePath &)> environment;
|
std::function<Environment(const FilePath &)> environment;
|
||||||
|
@@ -422,11 +422,14 @@ DeviceManager::DeviceManager(bool isInstance) : d(std::make_unique<DeviceManager
|
|||||||
return device->localSource(file);
|
return device->localSource(file);
|
||||||
};
|
};
|
||||||
|
|
||||||
deviceHooks.fileAccess = [](const FilePath &filePath) -> DeviceFileAccess * {
|
deviceHooks.fileAccess = [](const FilePath &filePath) -> expected_str<DeviceFileAccess *> {
|
||||||
if (!filePath.needsDevice())
|
if (!filePath.needsDevice())
|
||||||
return DesktopDeviceFileAccess::instance();
|
return DesktopDeviceFileAccess::instance();
|
||||||
auto device = DeviceManager::deviceForPath(filePath);
|
auto device = DeviceManager::deviceForPath(filePath);
|
||||||
QTC_ASSERT(device, qDebug() << filePath.toString(); return nullptr);
|
if (!device) {
|
||||||
|
return make_unexpected(
|
||||||
|
QString("No device found for path \"%1\"").arg(filePath.toUserOutput()));
|
||||||
|
}
|
||||||
return device->fileAccess();
|
return device->fileAccess();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user