From 01d377757435436aff41120845194534c34230a1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 9 Aug 2018 11:14:40 +0200 Subject: [PATCH] decoder/Thread, ...: log all exceptions --- src/Main.cxx | 4 ++-- src/StateFile.cxx | 8 ++++---- src/command/OtherCommands.cxx | 4 ++-- src/db/plugins/simple/SimpleDatabasePlugin.cxx | 4 ++-- src/db/update/Walk.cxx | 8 ++++---- src/decoder/DecoderThread.cxx | 3 +-- src/decoder/plugins/FfmpegDecoderPlugin.cxx | 4 ++-- src/lib/upnp/Discovery.cxx | 4 ++-- 8 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/Main.cxx b/src/Main.cxx index c789cb913..53162b33b 100644 --- a/src/Main.cxx +++ b/src/Main.cxx @@ -545,8 +545,8 @@ int mpd_main(int argc, char *argv[]) noexcept try { return MainOrThrow(argc, argv); - } catch (const std::exception &e) { - LogError(e); + } catch (...) { + LogError(std::current_exception()); return EXIT_FAILURE; } } diff --git a/src/StateFile.cxx b/src/StateFile.cxx index a106a509c..7c13fb9b2 100644 --- a/src/StateFile.cxx +++ b/src/StateFile.cxx @@ -102,8 +102,8 @@ StateFile::Write() FileOutputStream fos(config.path); Write(fos); fos.Commit(); - } catch (const std::exception &e) { - LogError(e); + } catch (...) { + LogError(std::current_exception()); } RememberVersions(); @@ -143,8 +143,8 @@ try { } RememberVersions(); -} catch (const std::exception &e) { - LogError(e); +} catch (...) { + LogError(std::current_exception()); } void diff --git a/src/command/OtherCommands.cxx b/src/command/OtherCommands.cxx index 2401a5845..228d5ea40 100644 --- a/src/command/OtherCommands.cxx +++ b/src/command/OtherCommands.cxx @@ -179,8 +179,8 @@ handle_lsinfo_relative(Client &client, Response &r, const char *uri) if (isRootDirectory(uri)) { try { print_spl_list(r, ListPlaylistFiles()); - } catch (const std::exception &e) { - LogError(e); + } catch (...) { + LogError(std::current_exception()); } } else { #ifndef ENABLE_DATABASE diff --git a/src/db/plugins/simple/SimpleDatabasePlugin.cxx b/src/db/plugins/simple/SimpleDatabasePlugin.cxx index 94510110c..52e46f76d 100644 --- a/src/db/plugins/simple/SimpleDatabasePlugin.cxx +++ b/src/db/plugins/simple/SimpleDatabasePlugin.cxx @@ -175,8 +175,8 @@ SimpleDatabase::Open() try { Load(); - } catch (const std::exception &e) { - LogError(e); + } catch (...) { + LogError(std::current_exception()); delete root; diff --git a/src/db/update/Walk.cxx b/src/db/update/Walk.cxx index 2c8990cf3..2cc9fa51f 100644 --- a/src/db/update/Walk.cxx +++ b/src/db/update/Walk.cxx @@ -234,8 +234,8 @@ try { FormatDebug(update_domain, "%s is not a directory, archive or music", name); } -} catch (const std::exception &e) { - LogError(e); +} catch (...) { + LogError(std::current_exception()); } /* we don't look at "." / ".." nor files with newlines in their name */ @@ -477,8 +477,8 @@ try { ExcludeList exclude_list; UpdateDirectoryChild(*parent, exclude_list, name, info); -} catch (const std::exception &e) { - LogError(e); +} catch (...) { + LogError(std::current_exception()); } bool diff --git a/src/decoder/DecoderThread.cxx b/src/decoder/DecoderThread.cxx index 43fbece73..0e4a34fab 100644 --- a/src/decoder/DecoderThread.cxx +++ b/src/decoder/DecoderThread.cxx @@ -536,9 +536,8 @@ DecoderControl::RunThread() noexcept if (state == DecoderState::ERROR) { try { std::rethrow_exception(error); - } catch (const std::exception &e) { - LogError(e); } catch (...) { + LogError(std::current_exception()); } } diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx index b65fd0284..c6d0290b4 100644 --- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx +++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx @@ -255,9 +255,9 @@ FfmpegSendFrame(DecoderClient &client, InputStream &is, try { output_buffer = copy_interleave_frame(codec_context, frame, buffer); - } catch (const std::exception &e) { + } catch (...) { /* this must be a serious error, e.g. OOM */ - LogError(e); + LogError(std::current_exception()); return DecoderCommand::STOP; } diff --git a/src/lib/upnp/Discovery.cxx b/src/lib/upnp/Discovery.cxx index 9a4b52712..83df66bd7 100644 --- a/src/lib/upnp/Discovery.cxx +++ b/src/lib/upnp/Discovery.cxx @@ -81,8 +81,8 @@ UPnPDeviceDirectory::Downloader::OnEnd() try { d.Parse(url, data.c_str()); - } catch (const std::exception &e) { - LogError(e); + } catch (...) { + LogError(std::current_exception()); } parent.LockAdd(std::move(d));