Main, ...: catch any exception, not just std::runtime_error

This commit is contained in:
Max Kellermann
2017-12-19 10:56:23 +01:00
parent a539094c06
commit 914df18bf9
79 changed files with 236 additions and 244 deletions

View File

@@ -361,10 +361,10 @@ ProxyDatabase::Open()
try {
Connect();
} catch (const std::runtime_error &error) {
} catch (...) {
/* this error is non-fatal, because this plugin will
attempt to reconnect again automatically */
LogError(error);
LogError(std::current_exception());
}
}
@@ -473,8 +473,8 @@ ProxyDatabase::OnSocketReady(gcc_unused unsigned flags) noexcept
if (idle == 0) {
try {
CheckError(connection);
} catch (const std::runtime_error &error) {
LogError(error);
} catch (...) {
LogError(std::current_exception());
Disconnect();
return false;
}
@@ -508,8 +508,8 @@ ProxyDatabase::OnIdle() noexcept
if (!mpd_send_idle_mask(connection, MPD_IDLE_DATABASE)) {
try {
ThrowError(connection);
} catch (const std::runtime_error &error) {
LogError(error);
} catch (...) {
LogError(std::current_exception());
}
SocketMonitor::Steal();

View File

@@ -34,7 +34,7 @@
#include "Log.hxx"
#include <string>
#include <stdexcept>
#include <exception>
#include <string.h>
@@ -153,8 +153,8 @@ UpdateWalk::UpdateArchiveFile(Directory &parent, const char *name,
ArchiveFile *file;
try {
file = archive_file_open(&plugin, path_fs);
} catch (const std::runtime_error &e) {
LogError(e);
} catch (...) {
LogError(std::current_exception());
if (directory != nullptr)
editor.LockDeleteDirectory(directory);
return;

View File

@@ -119,9 +119,9 @@ UpdateWalk::UpdateContainerFile(Directory &directory,
modified = true;
}
} catch (const std::runtime_error &e) {
} catch (...) {
LogError(std::current_exception());
editor.LockDeleteDirectory(contdir);
LogError(e);
return false;
}

View File

@@ -31,7 +31,7 @@
#include "util/StringStrip.hxx"
#include "Log.hxx"
#include <stdexcept>
#include <exception>
#include <assert.h>
#include <string.h>
@@ -62,8 +62,8 @@ try {
if (!IsFileNotFound(e))
LogError(e);
return false;
} catch (const std::exception &e) {
LogError(e);
} catch (...) {
LogError(std::current_exception());
return false;
}
@@ -85,7 +85,7 @@ ExcludeList::Check(Path name_fs) const noexcept
try {
if (i.Check(NarrowPath(name_fs).c_str()))
return true;
} catch (const std::runtime_error &) {
} catch (...) {
}
}
#else

View File

@@ -187,8 +187,8 @@ recursive_watch_subdirectories(WatchDirectory *directory,
FileInfo fi;
try {
fi = FileInfo(child_path_fs);
} catch (const std::runtime_error &e) {
LogError(e);
} catch (...) {
LogError(std::current_exception());
continue;
}
@@ -198,8 +198,8 @@ recursive_watch_subdirectories(WatchDirectory *directory,
try {
ret = inotify_source->Add(child_path_fs.c_str(),
IN_MASK);
} catch (const std::runtime_error &e) {
FormatError(e,
} catch (...) {
FormatError(std::current_exception(),
"Failed to register %s",
child_path_fs.c_str());
continue;
@@ -302,8 +302,8 @@ mpd_inotify_init(EventLoop &loop, Storage &storage, UpdateService &update,
inotify_source = new InotifySource(loop,
mpd_inotify_callback,
nullptr);
} catch (const std::runtime_error &e) {
LogError(e);
} catch (...) {
LogError(std::current_exception());
return;
}
@@ -312,8 +312,8 @@ mpd_inotify_init(EventLoop &loop, Storage &storage, UpdateService &update,
int descriptor;
try {
descriptor = inotify_source->Add(path.c_str(), IN_MASK);
} catch (const std::runtime_error &e) {
LogError(e);
} catch (...) {
LogError(std::current_exception());
delete inotify_source;
inotify_source = nullptr;
return;

View File

@@ -36,8 +36,8 @@ GetInfo(Storage &storage, const char *uri_utf8, StorageFileInfo &info) noexcept
try {
info = storage.GetInfo(uri_utf8, true);
return true;
} catch (const std::runtime_error &e) {
LogError(e);
} catch (...) {
LogError(std::current_exception());
return false;
}
@@ -46,8 +46,8 @@ GetInfo(StorageDirectoryReader &reader, StorageFileInfo &info) noexcept
try {
info = reader.GetInfo(true);
return true;
} catch (const std::runtime_error &e) {
LogError(e);
} catch (...) {
LogError(std::current_exception());
return false;
}
@@ -58,7 +58,7 @@ DirectoryExists(Storage &storage, const Directory &directory) noexcept
try {
info = storage.GetInfo(directory.GetPath(), true);
} catch (const std::runtime_error &) {
} catch (...) {
return false;
}
@@ -83,7 +83,7 @@ directory_child_is_regular(Storage &storage, const Directory &directory,
try {
return GetDirectoryChildInfo(storage, directory, name_utf8)
.IsRegular();
} catch (const std::runtime_error &) {
} catch (...) {
return false;
}

View File

@@ -338,8 +338,8 @@ UpdateWalk::UpdateDirectory(Directory &directory,
try {
reader.reset(storage.OpenDirectory(directory.GetPath()));
} catch (const std::runtime_error &e) {
LogError(e);
} catch (...) {
LogError(std::current_exception());
return false;
}