lib/upnp: use C++ exceptions instead of class Error

This commit is contained in:
Max Kellermann
2016-02-07 00:29:06 +01:00
parent 6e2ad6860f
commit 3ee5093b03
11 changed files with 143 additions and 230 deletions

View File

@@ -70,17 +70,19 @@ private:
};
bool
UpnpNeighborExplorer::Open(Error &error)
UpnpNeighborExplorer::Open(gcc_unused Error &error)
{
UpnpClient_Handle handle;
if (!UpnpClientGlobalInit(handle, error))
return false;
UpnpClientGlobalInit(handle);
discovery = new UPnPDeviceDirectory(handle, this);
if (!discovery->Start(error)) {
try {
discovery->Start();
} catch (...) {
delete discovery;
UpnpClientGlobalFinish();
return false;
throw;
}
return true;
@@ -98,10 +100,10 @@ UpnpNeighborExplorer::GetList() const
{
std::vector<ContentDirectoryService> tmp;
{
Error error;
if (!discovery->GetDirectories(tmp, error))
LogError(error);
try {
tmp = discovery->GetDirectories();
} catch (const std::runtime_error &e) {
LogError(e);
}
List result;