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

@ -32,7 +32,7 @@
#endif #endif
#endif #endif
#include <stdexcept> #include <exception>
Instance::Instance() Instance::Instance()
:idle_monitor(event_loop, BIND_THIS_METHOD(OnIdle)) :idle_monitor(event_loop, BIND_THIS_METHOD(OnIdle))
@ -84,7 +84,7 @@ Instance::OnDatabaseSongRemoved(const char *uri)
if (sticker_enabled()) { if (sticker_enabled()) {
try { try {
sticker_song_delete(uri); sticker_song_delete(uri);
} catch (const std::runtime_error &) { } catch (...) {
} }
} }
#endif #endif

View File

@ -120,7 +120,7 @@ listen_global_init(EventLoop &loop, Partition &partition)
do { do {
try { try {
listen_add_config_param(port, param); listen_add_config_param(port, param);
} catch (const std::runtime_error &e) { } catch (...) {
delete listen_socket; delete listen_socket;
std::throw_with_nested(FormatRuntimeError("Failed to listen on %s (line %i)", std::throw_with_nested(FormatRuntimeError("Failed to listen on %s (line %i)",
param->value.c_str(), param->value.c_str(),
@ -133,7 +133,7 @@ listen_global_init(EventLoop &loop, Partition &partition)
try { try {
listen_socket->AddPort(port); listen_socket->AddPort(port);
} catch (const std::runtime_error &e) { } catch (...) {
delete listen_socket; delete listen_socket;
std::throw_with_nested(FormatRuntimeError("Failed to listen on *:%d: ", port)); std::throw_with_nested(FormatRuntimeError("Failed to listen on *:%d: ", port));
} }
@ -141,7 +141,7 @@ listen_global_init(EventLoop &loop, Partition &partition)
try { try {
listen_socket->Open(); listen_socket->Open();
} catch (const std::runtime_error &e) { } catch (...) {
delete listen_socket; delete listen_socket;
throw; throw;
} }

View File

@ -379,7 +379,7 @@ initialize_decoder_and_player(const ReplayGainConfig &replay_gain_config)
try { try {
configured_audio_format = ParseAudioFormat(param->value.c_str(), configured_audio_format = ParseAudioFormat(param->value.c_str(),
true); true);
} catch (const std::runtime_error &) { } catch (...) {
std::throw_with_nested(FormatRuntimeError("error parsing line %i", std::throw_with_nested(FormatRuntimeError("error parsing line %i",
param->line)); param->line));
} }

View File

@ -32,7 +32,7 @@
#include "fs/io/BufferedOutputStream.hxx" #include "fs/io/BufferedOutputStream.hxx"
#include "util/UriUtil.hxx" #include "util/UriUtil.hxx"
#include <stdexcept> #include <exception>
static void static void
playlist_print_path(BufferedOutputStream &os, const Path path) playlist_print_path(BufferedOutputStream &os, const Path path)
@ -57,7 +57,7 @@ playlist_print_song(BufferedOutputStream &os, const DetachedSong &song)
try { try {
const auto uri_fs = AllocatedPath::FromUTF8Throw(uri_utf8); const auto uri_fs = AllocatedPath::FromUTF8Throw(uri_utf8);
playlist_print_path(os, uri_fs); playlist_print_path(os, uri_fs);
} catch (const std::runtime_error &) { } catch (...) {
} }
} }
@ -76,7 +76,7 @@ playlist_print_uri(BufferedOutputStream &os, const char *uri)
if (!path.IsNull()) if (!path.IsNull())
playlist_print_path(os, path); playlist_print_path(os, path);
} catch (const std::runtime_error &) { } catch (...) {
} }
} }

View File

@ -30,7 +30,7 @@
#include "util/UriUtil.hxx" #include "util/UriUtil.hxx"
#include "lib/icu/CaseFold.hxx" #include "lib/icu/CaseFold.hxx"
#include <stdexcept> #include <exception>
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>
@ -190,7 +190,7 @@ ParseTimeStamp(const char *s)
try { try {
/* try ISO 8601 */ /* try ISO 8601 */
return ParseTimePoint(s, "%FT%TZ"); return ParseTimePoint(s, "%FT%TZ");
} catch (const std::runtime_error &) { } catch (...) {
return std::chrono::system_clock::time_point::min(); return std::chrono::system_clock::time_point::min();
} }
} }

View File

@ -34,7 +34,7 @@
#include "TagArchive.hxx" #include "TagArchive.hxx"
#endif #endif
#include <stdexcept> #include <exception>
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
@ -68,7 +68,7 @@ Song::UpdateFile(Storage &storage)
StorageFileInfo info; StorageFileInfo info;
try { try {
info = storage.GetInfo(relative_uri.c_str(), true); info = storage.GetInfo(relative_uri.c_str(), true);
} catch (const std::runtime_error &) { } catch (...) {
return false; return false;
} }

View File

@ -77,8 +77,8 @@ stats_update(const Database &db)
stats = db.GetStats(selection); stats = db.GetStats(selection);
stats_validity = StatsValidity::VALID; stats_validity = StatsValidity::VALID;
return true; return true;
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
stats_validity = StatsValidity::FAILED; stats_validity = StatsValidity::FAILED;
return false; return false;
} }

View File

@ -29,7 +29,7 @@
#include "input/LocalOpen.hxx" #include "input/LocalOpen.hxx"
#include "thread/Cond.hxx" #include "thread/Cond.hxx"
#include <stdexcept> #include <exception>
#include <assert.h> #include <assert.h>
@ -64,13 +64,13 @@ public:
try { try {
is = OpenLocalInputStream(path_fs, is = OpenLocalInputStream(path_fs,
mutex, cond); mutex, cond);
} catch (const std::runtime_error &) { } catch (...) {
return false; return false;
} }
} else { } else {
try { try {
is->LockRewind(); is->LockRewind();
} catch (const std::runtime_error &) { } catch (...) {
} }
} }

View File

@ -30,7 +30,7 @@
#include "thread/Mutex.hxx" #include "thread/Mutex.hxx"
#include "thread/Cond.hxx" #include "thread/Cond.hxx"
#include <stdexcept> #include <exception>
#include <assert.h> #include <assert.h>
@ -66,7 +66,7 @@ tag_stream_scan(InputStream &is, const TagHandler &handler, void *ctx)
&handler, ctx](const DecoderPlugin &plugin){ &handler, ctx](const DecoderPlugin &plugin){
try { try {
is.LockRewind(); is.LockRewind();
} catch (const std::runtime_error &) { } catch (...) {
} }
return CheckDecoderPlugin(plugin, suffix, mime) && return CheckDecoderPlugin(plugin, suffix, mime) &&

View File

@ -68,7 +68,7 @@ handle_listfiles_storage(Response &r, StorageDirectoryReader &reader)
StorageFileInfo info; StorageFileInfo info;
try { try {
info = reader.GetInfo(false); info = reader.GetInfo(false);
} catch (const std::runtime_error &) { } catch (...) {
continue; continue;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -416,7 +416,7 @@ try {
assert(nbytes > 0 || is.IsEOF()); assert(nbytes > 0 || is.IsEOF());
return nbytes; return nbytes;
} catch (const std::runtime_error &e) { } catch (...) {
error = std::current_exception(); error = std::current_exception();
return 0; return 0;
} }
@ -471,7 +471,7 @@ DecoderBridge::SubmitData(InputStream *is,
auto result = convert->Convert({data, length}); auto result = convert->Convert({data, length});
data = result.data; data = result.data;
length = result.size; length = result.size;
} catch (const std::runtime_error &e) { } catch (...) {
/* the PCM conversion has failed - stop /* the PCM conversion has failed - stop
playback, since we have no better way to playback, since we have no better way to
bail out */ bail out */

View File

@ -37,8 +37,8 @@ decoder_read(DecoderClient *client,
try { try {
return is.LockRead(buffer, length); return is.LockRead(buffer, length);
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
return 0; return 0;
} }
} }

View File

@ -112,7 +112,7 @@ decoder_stream_decode(const DecoderPlugin &plugin,
/* rewind the stream, so each plugin gets a fresh start */ /* rewind the stream, so each plugin gets a fresh start */
try { try {
input_stream.Rewind(); input_stream.Rewind();
} catch (const std::runtime_error &) { } catch (...) {
} }
{ {

View File

@ -30,7 +30,7 @@
#include <audiofile.h> #include <audiofile.h>
#include <af_vfs.h> #include <af_vfs.h>
#include <stdexcept> #include <exception>
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
@ -120,8 +120,8 @@ audiofile_file_seek(AFvirtualfile *vfile, AFfileoffset _offset,
try { try {
is.LockSeek(offset); is.LockSeek(offset);
return is.GetOffset(); return is.GetOffset();
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e, "Seek failed"); LogError(std::current_exception(), "Seek failed");
return -1; return -1;
} }
} }

View File

@ -57,7 +57,7 @@ dsdlib_skip_to(DecoderClient *client, InputStream &is,
if (is.IsSeekable()) { if (is.IsSeekable()) {
try { try {
is.LockSeek(offset); is.LockSeek(offset);
} catch (const std::runtime_error &) { } catch (...) {
return false; return false;
} }
} }
@ -81,7 +81,7 @@ dsdlib_skip(DecoderClient *client, InputStream &is,
if (is.IsSeekable()) { if (is.IsSeekable()) {
try { try {
is.LockSeek(is.GetOffset() + delta); is.LockSeek(is.GetOffset() + delta);
} catch (const std::runtime_error &) { } catch (...) {
return false; return false;
} }
} }

View File

@ -31,7 +31,7 @@
#include <neaacdec.h> #include <neaacdec.h>
#include <stdexcept> #include <exception>
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
@ -196,7 +196,7 @@ faad_song_duration(DecoderBuffer &buffer, InputStream &is)
try { try {
is.LockSeek(tagsize); is.LockSeek(tagsize);
} catch (const std::runtime_error &) { } catch (...) {
} }
buffer.Clear(); buffer.Clear();
@ -316,7 +316,7 @@ faad_get_file_time(InputStream &is)
try { try {
faad_decoder_init(decoder, buffer, audio_format); faad_decoder_init(decoder, buffer, audio_format);
recognized = true; recognized = true;
} catch (const std::runtime_error &e) { } catch (...) {
} }
} }

View File

@ -483,7 +483,7 @@ ffmpeg_probe(DecoderClient *client, InputStream &is)
try { try {
is.LockRewind(); is.LockRewind();
} catch (const std::runtime_error &) { } catch (...) {
return nullptr; return nullptr;
} }
@ -814,8 +814,8 @@ ffmpeg_decode(DecoderClient &client, InputStream &input)
try { try {
format_context =FfmpegOpenInput(stream.io, input.GetURI(), format_context =FfmpegOpenInput(stream.io, input.GetURI(),
input_format); input_format);
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
return; return;
} }
@ -869,7 +869,7 @@ ffmpeg_scan_stream(InputStream &is,
AVFormatContext *f; AVFormatContext *f;
try { try {
f = FfmpegOpenInput(stream.io, is.GetURI(), input_format); f = FfmpegOpenInput(stream.io, is.GetURI(), input_format);
} catch (const std::runtime_error &) { } catch (...) {
return false; return false;
} }

View File

@ -25,7 +25,7 @@
#include "../DecoderAPI.hxx" #include "../DecoderAPI.hxx"
#include "input/InputStream.hxx" #include "input/InputStream.hxx"
#include <stdexcept> #include <exception>
AvioStream::~AvioStream() AvioStream::~AvioStream()
{ {
@ -72,7 +72,7 @@ AvioStream::Seek(int64_t pos, int whence)
try { try {
input.LockSeek(pos); input.LockSeek(pos);
return input.GetOffset(); return input.GetOffset();
} catch (const std::runtime_error &) { } catch (...) {
return -1; return -1;
} }
} }

View File

@ -27,7 +27,7 @@
#include "util/ConstBuffer.hxx" #include "util/ConstBuffer.hxx"
#include "Log.hxx" #include "Log.hxx"
#include <stdexcept> #include <exception>
bool bool
FlacDecoder::Initialize(unsigned sample_rate, unsigned bits_per_sample, FlacDecoder::Initialize(unsigned sample_rate, unsigned bits_per_sample,
@ -39,8 +39,8 @@ FlacDecoder::Initialize(unsigned sample_rate, unsigned bits_per_sample,
try { try {
pcm_import.Open(sample_rate, bits_per_sample, pcm_import.Open(sample_rate, bits_per_sample,
channels); channels);
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
unsupported = true; unsupported = true;
return false; return false;
} }

View File

@ -330,7 +330,7 @@ oggflac_decode(DecoderClient &client, InputStream &input_stream)
moved it */ moved it */
try { try {
input_stream.LockRewind(); input_stream.LockRewind();
} catch (const std::runtime_error &) { } catch (...) {
} }
flac_decode_internal(client, input_stream, true); flac_decode_internal(client, input_stream, true);

View File

@ -55,7 +55,7 @@ FlacIORead(void *ptr, size_t size, size_t nmemb, FLAC__IOHandle handle)
: EINVAL; : EINVAL;
return 0; return 0;
#endif #endif
} catch (const std::runtime_error &) { } catch (...) {
/* just some random non-zero errno value */ /* just some random non-zero errno value */
errno = EINVAL; errno = EINVAL;
return 0; return 0;
@ -96,8 +96,8 @@ FlacIOSeek(FLAC__IOHandle handle, FLAC__int64 _offset, int whence)
try { try {
is->LockSeek(offset); is->LockSeek(offset);
return 0; return 0;
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
return -1; return -1;
} }
} }

View File

@ -25,7 +25,7 @@
#include "Log.hxx" #include "Log.hxx"
#include "Compiler.h" #include "Compiler.h"
#include <stdexcept> #include <exception>
FLAC__StreamDecoderReadStatus FLAC__StreamDecoderReadStatus
FlacInput::Read(FLAC__byte buffer[], size_t *bytes) FlacInput::Read(FLAC__byte buffer[], size_t *bytes)
@ -54,8 +54,8 @@ FlacInput::Seek(FLAC__uint64 absolute_byte_offset)
try { try {
input_stream.LockSeek(absolute_byte_offset); input_stream.LockSeek(absolute_byte_offset);
return FLAC__STREAM_DECODER_SEEK_STATUS_OK; return FLAC__STREAM_DECODER_SEEK_STATUS_OK;
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR;
} }
} }

View File

@ -212,7 +212,7 @@ MadDecoder::Seek(long offset)
{ {
try { try {
input_stream.LockSeek(offset); input_stream.LockSeek(offset);
} catch (const std::runtime_error &) { } catch (...) {
return false; return false;
} }

View File

@ -32,7 +32,7 @@
#include <mpc/mpcdec.h> #include <mpc/mpcdec.h>
#include <stdexcept> #include <exception>
#include <math.h> #include <math.h>
@ -67,7 +67,7 @@ mpc_seek_cb(mpc_reader *reader, mpc_int32_t offset)
try { try {
data->is.LockSeek(offset); data->is.LockSeek(offset);
return true; return true;
} catch (const std::runtime_error &) { } catch (...) {
return false; return false;
} }
} }

View File

@ -22,7 +22,7 @@
#include "lib/xiph/OggFind.hxx" #include "lib/xiph/OggFind.hxx"
#include "input/InputStream.hxx" #include "input/InputStream.hxx"
#include <stdexcept> #include <exception>
/** /**
* Load the end-of-stream packet and restore the previous file * Load the end-of-stream packet and restore the previous file
@ -55,7 +55,7 @@ OggDecoder::LoadEndPacket(ogg_packet &packet) const
/* restore the previous file position */ /* restore the previous file position */
try { try {
input_stream.LockSeek(old_offset); input_stream.LockSeek(old_offset);
} catch (const std::runtime_error &) { } catch (...) {
} }
return result; return result;

View File

@ -261,7 +261,7 @@ MPDOpusDecoder::Seek(uint64_t where_frame)
try { try {
SeekGranulePos(where_granulepos); SeekGranulePos(where_granulepos);
return true; return true;
} catch (const std::runtime_error &) { } catch (...) {
return false; return false;
} }
} }
@ -277,7 +277,7 @@ mpd_opus_stream_decode(DecoderClient &client,
moved it */ moved it */
try { try {
input_stream.LockRewind(); input_stream.LockRewind();
} catch (const std::runtime_error &) { } catch (...) {
} }
DecoderReader reader(client, input_stream); DecoderReader reader(client, input_stream);

View File

@ -31,7 +31,7 @@
#include "util/MimeType.hxx" #include "util/MimeType.hxx"
#include "Log.hxx" #include "Log.hxx"
#include <stdexcept> #include <exception>
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
@ -105,8 +105,8 @@ pcm_stream_decode(DecoderClient &client, InputStream &is)
try { try {
CheckSampleRate(value); CheckSampleRate(value);
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
return; return;
} }
@ -127,8 +127,8 @@ pcm_stream_decode(DecoderClient &client, InputStream &is)
try { try {
CheckChannelCount(value); CheckChannelCount(value);
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
return; return;
} }
@ -196,8 +196,8 @@ pcm_stream_decode(DecoderClient &client, InputStream &is)
is.LockSeek(offset); is.LockSeek(offset);
buffer.Clear(); buffer.Clear();
client.CommandFinished(); client.CommandFinished();
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
client.SeekError(); client.SeekError();
} }

View File

@ -26,7 +26,7 @@
#include "util/Domain.hxx" #include "util/Domain.hxx"
#include "Log.hxx" #include "Log.hxx"
#include <stdexcept> #include <exception>
#include <sndfile.h> #include <sndfile.h>
@ -93,8 +93,8 @@ sndfile_vio_seek(sf_count_t _offset, int whence, void *user_data)
try { try {
is.LockSeek(offset); is.LockSeek(offset);
return is.GetOffset(); return is.GetOffset();
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e, "Seek failed"); LogError(std::current_exception(), "Seek failed");
return -1; return -1;
} }
} }

View File

@ -129,7 +129,7 @@ VorbisDecoder::Seek(uint64_t where_frame)
SeekGranulePos(where_granulepos); SeekGranulePos(where_granulepos);
vorbis_synthesis_restart(&dsp); vorbis_synthesis_restart(&dsp);
return true; return true;
} catch (const std::runtime_error &) { } catch (...) {
return false; return false;
} }
} }
@ -323,7 +323,7 @@ vorbis_stream_decode(DecoderClient &client,
moved it */ moved it */
try { try {
input_stream.LockRewind(); input_stream.LockRewind();
} catch (const std::runtime_error &) { } catch (...) {
} }
DecoderReader reader(client, input_stream); DecoderReader reader(client, input_stream);

View File

@ -295,7 +295,7 @@ struct WavpackInput {
try { try {
is.LockSeek(pos); is.LockSeek(pos);
return 0; return 0;
} catch (const std::runtime_error &) { } catch (...) {
return -1; return -1;
} }
} }
@ -520,7 +520,7 @@ wavpack_open_wvc(DecoderClient &client, const char *uri)
try { try {
return client.OpenUri(uri); return client.OpenUri(uri);
} catch (const std::runtime_error &) { } catch (...) {
return nullptr; return nullptr;
} }
} }

View File

@ -220,11 +220,11 @@ ServerSocket::Open()
try { try {
i.Open(); i.Open();
} catch (const std::runtime_error &e) { } catch (...) {
if (good != nullptr && good->GetSerial() == i.GetSerial()) { if (good != nullptr && good->GetSerial() == i.GetSerial()) {
const auto address_string = i.ToString(); const auto address_string = i.ToString();
const auto good_string = good->ToString(); const auto good_string = good->ToString();
FormatError(e, FormatError(std::current_exception(),
"bind to '%s' failed " "bind to '%s' failed "
"(continuing anyway, because " "(continuing anyway, because "
"binding to '%s' succeeded)", "binding to '%s' succeeded)",

View File

@ -29,7 +29,7 @@
#include "util/Domain.hxx" #include "util/Domain.hxx"
#include "Log.hxx" #include "Log.hxx"
#include <stdexcept> #include <exception>
#include <assert.h> #include <assert.h>
@ -163,8 +163,9 @@ ReplayGainFilter::Update()
try { try {
mixer_set_volume(mixer, _volume); mixer_set_volume(mixer, _volume);
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e, "Failed to update hardware mixer"); LogError(std::current_exception(),
"Failed to update hardware mixer");
} }
} else } else
pv.SetVolume(volume); pv.SetVolume(volume);

View File

@ -23,7 +23,7 @@
#include "Charset.hxx" #include "Charset.hxx"
#include "Compiler.h" #include "Compiler.h"
#include <stdexcept> #include <exception>
/* no inlining, please */ /* no inlining, please */
AllocatedPath::~AllocatedPath() {} AllocatedPath::~AllocatedPath() {}
@ -34,7 +34,7 @@ AllocatedPath::FromUTF8(const char *path_utf8) noexcept
#if defined(HAVE_FS_CHARSET) || defined(_WIN32) #if defined(HAVE_FS_CHARSET) || defined(_WIN32)
try { try {
return AllocatedPath(::PathFromUTF8(path_utf8)); return AllocatedPath(::PathFromUTF8(path_utf8));
} catch (const std::runtime_error &) { } catch (...) {
return nullptr; return nullptr;
} }
#else #else
@ -63,7 +63,7 @@ AllocatedPath::ToUTF8() const noexcept
{ {
try { try {
return ::PathToUTF8(c_str()); return ::PathToUTF8(c_str());
} catch (const std::runtime_error &) { } catch (...) {
return std::string(); return std::string();
} }
} }

View File

@ -62,6 +62,6 @@ try {
"No permission to read directory: %s", "No permission to read directory: %s",
path_fs.ToUTF8().c_str()); path_fs.ToUTF8().c_str());
} }
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
} }

View File

@ -21,14 +21,12 @@
#include "Path.hxx" #include "Path.hxx"
#include "Charset.hxx" #include "Charset.hxx"
#include <stdexcept>
std::string std::string
Path::ToUTF8() const noexcept Path::ToUTF8() const noexcept
{ {
try { try {
return ::PathToUTF8(c_str()); return ::PathToUTF8(c_str());
} catch (const std::runtime_error &) { } catch (...) {
return std::string(); return std::string();
} }
} }

View File

@ -62,7 +62,7 @@ input_stream_global_init(EventLoop &event_loop)
"Input plugin '%s' is unavailable", "Input plugin '%s' is unavailable",
plugin->name); plugin->name);
continue; continue;
} catch (const std::runtime_error &e) { } catch (...) {
std::throw_with_nested(FormatRuntimeError("Failed to initialize input plugin '%s'", std::throw_with_nested(FormatRuntimeError("Failed to initialize input plugin '%s'",
plugin->name)); plugin->name));
} }

View File

@ -63,8 +63,8 @@ TextInputStream::ReadLine()
try { try {
nbytes = is->LockRead(dest.data, dest.size); nbytes = is->LockRead(dest.data, dest.size);
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
return nullptr; return nullptr;
} }

View File

@ -42,7 +42,6 @@
#endif #endif
#include <memory> #include <memory>
#include <stdexcept>
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
@ -95,7 +94,7 @@ try {
#else #else
#error not implemented #error not implemented
#endif #endif
} catch (const std::runtime_error &) { } catch (...) {
return AllocatedString<>::Duplicate(src); return AllocatedString<>::Duplicate(src);
} }

View File

@ -97,7 +97,7 @@ IcuCollate(const char *a, const char *b) noexcept
return ucol_strcoll(collator, au.begin(), au.size(), return ucol_strcoll(collator, au.begin(), au.size(),
bu.begin(), bu.size()); bu.begin(), bu.size());
} catch (const std::runtime_error &) { } catch (...) {
/* fall back to plain strcasecmp() */ /* fall back to plain strcasecmp() */
return strcasecmp(a, b); return strcasecmp(a, b);
} }
@ -108,18 +108,18 @@ IcuCollate(const char *a, const char *b) noexcept
try { try {
wa = MultiByteToWideChar(CP_UTF8, a); wa = MultiByteToWideChar(CP_UTF8, a);
} catch (const std::runtime_error &) { } catch (...) {
try { try {
wb = MultiByteToWideChar(CP_UTF8, b); wb = MultiByteToWideChar(CP_UTF8, b);
return -1; return -1;
} catch (const std::runtime_error &) { } catch (...) {
return 0; return 0;
} }
} }
try { try {
wb = MultiByteToWideChar(CP_UTF8, b); wb = MultiByteToWideChar(CP_UTF8, b);
} catch (const std::runtime_error &) { } catch (...) {
return 1; return 1;
} }

View File

@ -22,8 +22,6 @@
#include "lib/xiph/OggSyncState.hxx" #include "lib/xiph/OggSyncState.hxx"
#include "input/InputStream.hxx" #include "input/InputStream.hxx"
#include <stdexcept>
bool bool
OggFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet) OggFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet)
{ {
@ -51,7 +49,7 @@ OggSeekPageAtOffset(OggSyncState &oy, ogg_stream_state &os, InputStream &is,
try { try {
is.LockSeek(offset); is.LockSeek(offset);
} catch (const std::runtime_error &) { } catch (...) {
return false; return false;
} }

View File

@ -43,8 +43,8 @@ output_mixer_get_volume(const AudioOutputControl &ao) noexcept
try { try {
return mixer_get_volume(mixer); return mixer_get_volume(mixer);
} catch (const std::runtime_error &e) { } catch (...) {
FormatError(e, FormatError(std::current_exception(),
"Failed to read mixer for '%s'", "Failed to read mixer for '%s'",
ao.GetName()); ao.GetName());
return -1; return -1;
@ -86,8 +86,8 @@ output_mixer_set_volume(AudioOutputControl &ao, unsigned volume) noexcept
try { try {
mixer_set_volume(mixer, volume); mixer_set_volume(mixer, volume);
return true; return true;
} catch (const std::runtime_error &e) { } catch (...) {
FormatError(e, FormatError(std::current_exception(),
"Failed to set mixer for '%s'", "Failed to set mixer for '%s'",
ao.GetName()); ao.GetName());
return false; return false;

View File

@ -149,7 +149,7 @@ alsa_mixer_elem_callback(snd_mixer_elem_t *elem, unsigned mask)
try { try {
int volume = mixer.GetVolume(); int volume = mixer.GetVolume();
mixer.listener.OnMixerVolumeChanged(mixer, volume); mixer.listener.OnMixerVolumeChanged(mixer, volume);
} catch (const std::runtime_error &) { } catch (...) {
} }
} }

View File

@ -104,8 +104,8 @@ UpnpNeighborExplorer::GetList() const noexcept
try { try {
tmp = discovery->GetDirectories(); tmp = discovery->GetDirectories();
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
} }
List result; List result;

View File

@ -205,8 +205,9 @@ AudioOutputControl::Open(const AudioFormat audio_format,
if (open2 && output->mixer != nullptr) { if (open2 && output->mixer != nullptr) {
try { try {
mixer_open(output->mixer); mixer_open(output->mixer);
} catch (const std::runtime_error &e) { } catch (...) {
FormatError(e, "Failed to open mixer for '%s'", FormatError(std::current_exception(),
"Failed to open mixer for '%s'",
GetName()); GetName());
} }
} }

View File

@ -45,7 +45,7 @@ FilteredAudioOutput::Enable()
{ {
try { try {
output->Enable(); output->Enable();
} catch (const std::runtime_error &e) { } catch (...) {
std::throw_with_nested(FormatRuntimeError("Failed to enable output %s", std::throw_with_nested(FormatRuntimeError("Failed to enable output %s",
GetLogName())); GetLogName()));
} }
@ -62,7 +62,7 @@ FilteredAudioOutput::ConfigureConvertFilter()
{ {
try { try {
convert_filter_set(convert_filter.Get(), out_audio_format); convert_filter_set(convert_filter.Get(), out_audio_format);
} catch (const std::runtime_error &e) { } catch (...) {
std::throw_with_nested(FormatRuntimeError("Failed to convert for %s", std::throw_with_nested(FormatRuntimeError("Failed to convert for %s",
GetLogName())); GetLogName()));
} }
@ -75,7 +75,7 @@ FilteredAudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
try { try {
output->Open(out_audio_format); output->Open(out_audio_format);
} catch (const std::runtime_error &e) { } catch (...) {
std::throw_with_nested(FormatRuntimeError("Failed to open %s", std::throw_with_nested(FormatRuntimeError("Failed to open %s",
GetLogName())); GetLogName()));
} }
@ -87,7 +87,7 @@ FilteredAudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
try { try {
ConfigureConvertFilter(); ConfigureConvertFilter();
} catch (const std::runtime_error &e) { } catch (...) {
output->Close(); output->Close();
if (out_audio_format.format == SampleFormat::DSD) { if (out_audio_format.format == SampleFormat::DSD) {
@ -97,7 +97,7 @@ FilteredAudioOutput::OpenOutputAndConvert(AudioFormat desired_audio_format)
implemented; our last resort is to give up implemented; our last resort is to give up
DSD and fall back to PCM */ DSD and fall back to PCM */
LogError(e); LogError(std::current_exception());
FormatError(output_domain, "Retrying without DSD"); FormatError(output_domain, "Retrying without DSD");
desired_audio_format.format = SampleFormat::FLOAT; desired_audio_format.format = SampleFormat::FLOAT;
@ -184,8 +184,8 @@ FilteredAudioOutput::IteratePause() noexcept
{ {
try { try {
return output->Pause(); return output->Pause();
} catch (const std::runtime_error &e) { } catch (...) {
FormatError(e, "Failed to pause %s", FormatError(std::current_exception(), "Failed to pause %s",
GetLogName()); GetLogName());
return false; return false;
} }

View File

@ -186,11 +186,11 @@ FilteredAudioOutput::Configure(const ConfigBlock &block)
try { try {
filter_chain_parse(*prepared_filter, filter_chain_parse(*prepared_filter,
block.GetBlockValue(AUDIO_FILTERS, "")); block.GetBlockValue(AUDIO_FILTERS, ""));
} catch (const std::runtime_error &e) { } catch (...) {
/* It's not really fatal - Part of the filter chain /* It's not really fatal - Part of the filter chain
has been set up already and even an empty one will has been set up already and even an empty one will
work (if only with unexpected behaviour) */ work (if only with unexpected behaviour) */
FormatError(e, FormatError(std::current_exception(),
"Failed to initialize filter chain for '%s'", "Failed to initialize filter chain for '%s'",
name); name);
} }
@ -232,8 +232,8 @@ FilteredAudioOutput::Setup(EventLoop &event_loop,
mixer_plugin, mixer_plugin,
*prepared_filter, *prepared_filter,
mixer_listener); mixer_listener);
} catch (const std::runtime_error &e) { } catch (...) {
FormatError(e, FormatError(std::current_exception(),
"Failed to initialize hardware mixer for '%s'", "Failed to initialize hardware mixer for '%s'",
name); name);
} }

View File

@ -57,7 +57,7 @@ LoadOutput(EventLoop &event_loop,
try { try {
return audio_output_new(event_loop, replay_gain_config, block, return audio_output_new(event_loop, replay_gain_config, block,
mixer_listener); mixer_listener);
} catch (const std::runtime_error &e) { } catch (...) {
if (block.line > 0) if (block.line > 0)
std::throw_with_nested(FormatRuntimeError("Failed to configure output in line %i", std::throw_with_nested(FormatRuntimeError("Failed to configure output in line %i",
block.line)); block.line));

View File

@ -72,7 +72,7 @@ AudioOutputControl::InternalOpen2(const AudioFormat in_audio_format)
try { try {
output->ConfigureConvertFilter(); output->ConfigureConvertFilter();
} catch (const std::runtime_error &e) { } catch (...) {
open = false; open = false;
{ {
@ -107,8 +107,8 @@ AudioOutputControl::InternalEnable() noexcept
really_enabled = true; really_enabled = true;
return true; return true;
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
fail_timer.Update(); fail_timer.Update();
last_error = std::current_exception(); last_error = std::current_exception();
return false; return false;
@ -149,7 +149,7 @@ AudioOutputControl::InternalOpen(const AudioFormat in_audio_format,
output->prepared_replay_gain_filter, output->prepared_replay_gain_filter,
output->prepared_other_replay_gain_filter, output->prepared_other_replay_gain_filter,
output->prepared_filter); output->prepared_filter);
} catch (const std::runtime_error &e) { } catch (...) {
std::throw_with_nested(FormatRuntimeError("Failed to open filter for %s", std::throw_with_nested(FormatRuntimeError("Failed to open filter for %s",
GetLogName())); GetLogName()));
} }
@ -160,8 +160,8 @@ AudioOutputControl::InternalOpen(const AudioFormat in_audio_format,
source.Close(); source.Close();
throw; throw;
} }
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
fail_timer.Update(); fail_timer.Update();
last_error = std::current_exception(); last_error = std::current_exception();
} }
@ -231,8 +231,9 @@ bool
AudioOutputControl::FillSourceOrClose() AudioOutputControl::FillSourceOrClose()
try { try {
return source.Fill(mutex); return source.Fill(mutex);
} catch (const std::runtime_error &e) { } catch (...) {
FormatError(e, "Failed to filter for %s", GetLogName()); FormatError(std::current_exception(),
"Failed to filter for %s", GetLogName());
InternalClose(false); InternalClose(false);
@ -251,8 +252,9 @@ AudioOutputControl::PlayChunk() noexcept
const ScopeUnlock unlock(mutex); const ScopeUnlock unlock(mutex);
try { try {
output->SendTag(*tag); output->SendTag(*tag);
} catch (const std::runtime_error &e) { } catch (...) {
FormatError(e, "Failed to send tag to %s", FormatError(std::current_exception(),
"Failed to send tag to %s",
GetLogName()); GetLogName());
} }
} }
@ -273,8 +275,9 @@ AudioOutputControl::PlayChunk() noexcept
const ScopeUnlock unlock(mutex); const ScopeUnlock unlock(mutex);
nbytes = output->Play(data.data, data.size); nbytes = output->Play(data.data, data.size);
assert(nbytes <= data.size); assert(nbytes <= data.size);
} catch (const std::runtime_error &e) { } catch (...) {
FormatError(e, "Failed to play on %s", GetLogName()); FormatError(std::current_exception(),
"Failed to play on %s", GetLogName());
nbytes = 0; nbytes = 0;
} }
@ -382,8 +385,8 @@ AudioOutputControl::Task()
try { try {
SetThreadRealtime(); SetThreadRealtime();
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e, LogError(std::current_exception(),
"OutputThread could not get realtime scheduling, continuing anyway"); "OutputThread could not get realtime scheduling, continuing anyway");
} }

View File

@ -875,7 +875,7 @@ try {
call */ call */
return; return;
} }
} catch (const std::runtime_error &) { } catch (...) {
MultiSocketMonitor::Reset(); MultiSocketMonitor::Reset();
LockCaughtError(); LockCaughtError();
} }

View File

@ -92,8 +92,8 @@ FifoOutput::Delete()
try { try {
RemoveFile(path); RemoveFile(path);
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e, "Could not remove FIFO"); LogError(std::current_exception(), "Could not remove FIFO");
return; return;
} }

View File

@ -856,7 +856,7 @@ try {
PulseOutput po(empty); PulseOutput po(empty);
po.WaitConnection(); po.WaitConnection();
return true; return true;
} catch (const std::runtime_error &e) { } catch (...) {
return false; return false;
} }

View File

@ -154,7 +154,7 @@ RecorderOutput::Open(AudioFormat &audio_format)
try { try {
encoder = prepared_encoder->Open(audio_format); encoder = prepared_encoder->Open(audio_format);
} catch (const std::runtime_error &) { } catch (...) {
delete file; delete file;
throw; throw;
} }
@ -162,7 +162,7 @@ RecorderOutput::Open(AudioFormat &audio_format)
if (!HasDynamicPath()) { if (!HasDynamicPath()) {
try { try {
EncoderToFile(); EncoderToFile();
} catch (const std::runtime_error &) { } catch (...) {
delete encoder; delete encoder;
throw; throw;
} }
@ -218,8 +218,8 @@ RecorderOutput::Close() noexcept
try { try {
Commit(); Commit();
} catch (const std::exception &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
} }
if (HasDynamicPath()) { if (HasDynamicPath()) {
@ -238,8 +238,8 @@ RecorderOutput::FinishFormat()
try { try {
Commit(); Commit();
} catch (const std::exception &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
} }
file = nullptr; file = nullptr;
@ -270,7 +270,7 @@ RecorderOutput::ReopenFormat(AllocatedPath &&new_path)
try { try {
EncoderToOutputStream(*new_file, *encoder); EncoderToOutputStream(*new_file, *encoder);
} catch (const std::exception &e) { } catch (...) {
delete encoder; delete encoder;
delete new_file; delete new_file;
throw; throw;
@ -302,8 +302,8 @@ RecorderOutput::SendTag(const Tag &tag)
try { try {
new_path = ParsePath(p); new_path = ParsePath(p);
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
FinishFormat(); FinishFormat();
return; return;
} }
@ -313,8 +313,8 @@ RecorderOutput::SendTag(const Tag &tag)
try { try {
ReopenFormat(std::move(new_path)); ReopenFormat(std::move(new_path));
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
return; return;
} }
} }

View File

@ -251,7 +251,7 @@ ShoutOutput::Close() noexcept
try { try {
encoder->End(); encoder->End();
WritePage(); WritePage();
} catch (const std::runtime_error &) { } catch (...) {
/* ignore */ /* ignore */
} }

View File

@ -179,7 +179,7 @@ HttpdOutput::ReadPage()
buffer underruns */ buffer underruns */
try { try {
encoder->Flush(); encoder->Flush();
} catch (const std::runtime_error &) { } catch (...) {
/* ignore */ /* ignore */
} }
@ -376,7 +376,7 @@ HttpdOutput::SendTag(const Tag &tag)
try { try {
encoder->PreTag(); encoder->PreTag();
} catch (const std::runtime_error &) { } catch (...) {
/* ignore */ /* ignore */
} }
@ -388,7 +388,7 @@ HttpdOutput::SendTag(const Tag &tag)
try { try {
encoder->SendTag(tag); encoder->SendTag(tag);
encoder->Flush(); encoder->Flush();
} catch (const std::runtime_error &) { } catch (...) {
/* ignore */ /* ignore */
} }

View File

@ -37,7 +37,7 @@
#include "thread/Name.hxx" #include "thread/Name.hxx"
#include "Log.hxx" #include "Log.hxx"
#include <stdexcept> #include <exception>
#include <string.h> #include <string.h>
@ -462,8 +462,8 @@ Player::OpenOutput()
try { try {
const ScopeUnlock unlock(pc.mutex); const ScopeUnlock unlock(pc.mutex);
pc.outputs.Open(play_audio_format, buffer); pc.outputs.Open(play_audio_format, buffer);
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
output_open = false; output_open = false;
@ -564,8 +564,8 @@ Player::SendSilence()
try { try {
pc.outputs.Play(chunk); pc.outputs.Play(chunk);
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
buffer.Return(chunk); buffer.Return(chunk);
return false; return false;
} }
@ -896,8 +896,8 @@ Player::PlayNextChunk()
try { try {
play_chunk(pc, *song, chunk, buffer, play_audio_format); play_chunk(pc, *song, chunk, buffer, play_audio_format);
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
buffer.Return(chunk); buffer.Return(chunk);

View File

@ -38,8 +38,6 @@
#include "config/ConfigGlobal.hxx" #include "config/ConfigGlobal.hxx"
#include "config/Block.hxx" #include "config/Block.hxx"
#include <stdexcept>
#include <assert.h> #include <assert.h>
#include <string.h> #include <string.h>
@ -196,7 +194,7 @@ playlist_list_open_stream_mime2(InputStreamPtr &&is, const char *mime)
fresh start */ fresh start */
try { try {
is->LockRewind(); is->LockRewind();
} catch (const std::runtime_error &) { } catch (...) {
} }
auto playlist = playlist_plugin_open_stream(plugin, auto playlist = playlist_plugin_open_stream(plugin,
@ -240,7 +238,7 @@ playlist_list_open_stream_suffix(InputStreamPtr &&is, const char *suffix)
fresh start */ fresh start */
try { try {
is->LockRewind(); is->LockRewind();
} catch (const std::runtime_error &) { } catch (...) {
} }
auto playlist = playlist_plugin_open_stream(plugin, auto playlist = playlist_plugin_open_stream(plugin,

View File

@ -26,8 +26,6 @@
#include "util/UriUtil.hxx" #include "util/UriUtil.hxx"
#include "DetachedSong.hxx" #include "DetachedSong.hxx"
#include <stdexcept>
#include <string.h> #include <string.h>
static void static void
@ -53,7 +51,7 @@ try {
merge_song_metadata(song, tmp); merge_song_metadata(song, tmp);
return true; return true;
} catch (const std::runtime_error &) { } catch (...) {
return false; return false;
} }

View File

@ -26,7 +26,7 @@
#include "fs/Path.hxx" #include "fs/Path.hxx"
#include "Log.hxx" #include "Log.hxx"
#include <stdexcept> #include <exception>
#include <assert.h> #include <assert.h>
@ -46,8 +46,8 @@ try {
auto is = OpenLocalInputStream(path, mutex, cond); auto is = OpenLocalInputStream(path, mutex, cond);
return playlist_list_open_stream_suffix(std::move(is), return playlist_list_open_stream_suffix(std::move(is),
suffix_utf8.c_str()); suffix_utf8.c_str());
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
return nullptr; return nullptr;
} }
@ -64,8 +64,8 @@ try {
playlist = playlist_open_path_suffix(path, mutex, cond); playlist = playlist_open_path_suffix(path, mutex, cond);
return playlist; return playlist;
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
return nullptr; return nullptr;
} }
@ -80,7 +80,7 @@ try {
auto is = InputStream::OpenReady(uri, mutex, cond); auto is = InputStream::OpenReady(uri, mutex, cond);
return playlist_list_open_stream(std::move(is), uri); return playlist_list_open_stream(std::move(is), uri);
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
return nullptr; return nullptr;
} }

View File

@ -23,8 +23,6 @@
#include "db/LightSong.hxx" #include "db/LightSong.hxx"
#include "DetachedSong.hxx" #include "DetachedSong.hxx"
#include <stdexcept>
static bool static bool
UpdatePlaylistSong(const Database &db, DetachedSong &song) UpdatePlaylistSong(const Database &db, DetachedSong &song)
{ {
@ -36,7 +34,7 @@ UpdatePlaylistSong(const Database &db, DetachedSong &song)
const LightSong *original; const LightSong *original;
try { try {
original = db.GetSong(song.GetURI()); original = db.GetSong(song.GetURI());
} catch (const std::runtime_error &e) { } catch (...) {
/* not found - shouldn't happen, because the update /* not found - shouldn't happen, because the update
thread should ensure that all stale Song instances thread should ensure that all stale Song instances
have been purged */ have been purged */

View File

@ -29,6 +29,8 @@
#include "util/StringCompare.hxx" #include "util/StringCompare.hxx"
#include "Log.hxx" #include "Log.hxx"
#include <exception>
#include <stdlib.h> #include <stdlib.h>
#define PRIO_LABEL "Prio: " #define PRIO_LABEL "Prio: "
@ -96,8 +98,8 @@ queue_load_song(TextFile &file, const SongLoader &loader,
try { try {
song = song_load(file, uri); song = song_load(file, uri);
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
return; return;
} }
} else { } else {

View File

@ -25,8 +25,6 @@
#include "util/Alloc.hxx" #include "util/Alloc.hxx"
#include "util/ScopeExit.hxx" #include "util/ScopeExit.hxx"
#include <stdexcept>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -96,7 +94,7 @@ sticker_song_find_cb(const char *uri, const char *value, void *user_data)
const LightSong *song = db->GetSong(uri); const LightSong *song = db->GetSong(uri);
data->func(*song, value, data->user_data); data->func(*song, value, data->user_data);
db->ReturnSong(song); db->ReturnSong(song);
} catch (const std::runtime_error &e) { } catch (...) {
} }
} }

View File

@ -299,7 +299,7 @@ CompositeStorage::OpenDirectory(const char *uri)
try { try {
other = f.directory->storage->OpenDirectory(f.uri); other = f.directory->storage->OpenDirectory(f.uri);
} catch (const std::runtime_error &) { } catch (...) {
} }
return new CompositeDirectoryReader(other, directory->children); return new CompositeDirectoryReader(other, directory->children);

View File

@ -194,7 +194,7 @@ ParseTimeStamp(const char *s)
try { try {
// TODO: make this more robust // TODO: make this more robust
return ParseTimePoint(s, "%a, %d %b %Y %T %Z"); return ParseTimePoint(s, "%a, %d %b %Y %T %Z");
} catch (const std::runtime_error &) { } catch (...) {
return std::chrono::system_clock::time_point::min(); return std::chrono::system_clock::time_point::min();
} }
} }

View File

@ -123,7 +123,7 @@ LocalStorage::MapFS(const char *uri_utf8) const noexcept
{ {
try { try {
return MapFSOrThrow(uri_utf8); return MapFSOrThrow(uri_utf8);
} catch (const std::runtime_error &) { } catch (...) {
return AllocatedPath::Null(); return AllocatedPath::Null();
} }
} }

View File

@ -24,7 +24,6 @@
#include "util/StringView.hxx" #include "util/StringView.hxx"
#include <memory> #include <memory>
#include <stdexcept>
#include <stdint.h> #include <stdint.h>
#include <assert.h> #include <assert.h>
@ -104,6 +103,6 @@ try {
} }
return true; return true;
} catch (const std::runtime_error &) { } catch (...) {
return false; return false;
} }

View File

@ -28,7 +28,7 @@
#include "input/LocalOpen.hxx" #include "input/LocalOpen.hxx"
#include "Log.hxx" #include "Log.hxx"
#include <stdexcept> #include <exception>
bool bool
ScanGenericTags(InputStream &is, const TagHandler &handler, void *ctx) ScanGenericTags(InputStream &is, const TagHandler &handler, void *ctx)
@ -39,7 +39,7 @@ ScanGenericTags(InputStream &is, const TagHandler &handler, void *ctx)
#ifdef ENABLE_ID3TAG #ifdef ENABLE_ID3TAG
try { try {
is.LockRewind(); is.LockRewind();
} catch (const std::runtime_error &) { } catch (...) {
return false; return false;
} }
@ -57,7 +57,7 @@ try {
auto is = OpenLocalInputStream(path, mutex, cond); auto is = OpenLocalInputStream(path, mutex, cond);
return ScanGenericTags(*is, handler, ctx); return ScanGenericTags(*is, handler, ctx);
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
return false; return false;
} }

View File

@ -27,7 +27,6 @@
#include <id3tag.h> #include <id3tag.h>
#include <algorithm> #include <algorithm>
#include <stdexcept>
static constexpr size_t ID3V1_SIZE = 128; static constexpr size_t ID3V1_SIZE = 128;
@ -46,7 +45,7 @@ try {
is.ReadFull(buf, sizeof(buf)); is.ReadFull(buf, sizeof(buf));
return id3_tag_query(buf, sizeof(buf)); return id3_tag_query(buf, sizeof(buf));
} catch (const std::runtime_error &) { } catch (...) {
return 0; return 0;
} }
@ -77,7 +76,7 @@ try {
is.ReadFull(end, remaining); is.ReadFull(end, remaining);
return UniqueId3Tag(id3_tag_parse(tag_buffer.get(), tag_size)); return UniqueId3Tag(id3_tag_parse(tag_buffer.get(), tag_size));
} catch (const std::runtime_error &) { } catch (...) {
return nullptr; return nullptr;
} }
@ -87,7 +86,7 @@ try {
is.Seek(offset); is.Seek(offset);
return ReadId3Tag(is); return ReadId3Tag(is);
} catch (const std::runtime_error &) { } catch (...) {
return nullptr; return nullptr;
} }
@ -98,7 +97,7 @@ try {
is.ReadFull(buffer, ID3V1_SIZE); is.ReadFull(buffer, ID3V1_SIZE);
return UniqueId3Tag(id3_tag_parse(buffer, ID3V1_SIZE)); return UniqueId3Tag(id3_tag_parse(buffer, ID3V1_SIZE));
} catch (const std::runtime_error &) { } catch (...) {
return nullptr; return nullptr;
} }
@ -107,7 +106,7 @@ ReadId3v1Tag(InputStream &is, offset_type offset)
try { try {
is.Seek(offset); is.Seek(offset);
return ReadId3v1Tag(is); return ReadId3v1Tag(is);
} catch (const std::runtime_error &) { } catch (...) {
return nullptr; return nullptr;
} }
@ -140,7 +139,7 @@ try {
} }
return tag; return tag;
} catch (const std::runtime_error &) { } catch (...) {
return nullptr; return nullptr;
} }
@ -181,7 +180,7 @@ try {
/* We have an id3v2 tag, so ditch v1tag */ /* We have an id3v2 tag, so ditch v1tag */
return tag; return tag;
} catch (const std::runtime_error &) { } catch (...) {
return nullptr; return nullptr;
} }
@ -191,7 +190,7 @@ try {
size_t size; size_t size;
try { try {
size = riff_seek_id3(is); size = riff_seek_id3(is);
} catch (const std::runtime_error &) { } catch (...) {
size = aiff_seek_id3(is); size = aiff_seek_id3(is);
} }
@ -203,7 +202,7 @@ try {
is.ReadFull(buffer.get(), size); is.ReadFull(buffer.get(), size);
return UniqueId3Tag(id3_tag_parse(buffer.get(), size)); return UniqueId3Tag(id3_tag_parse(buffer.get(), size));
} catch (const std::runtime_error &) { } catch (...) {
return nullptr; return nullptr;
} }
@ -220,6 +219,6 @@ try {
} }
return tag; return tag;
} catch (const std::runtime_error &) { } catch (...) {
return nullptr; return nullptr;
} }

View File

@ -32,7 +32,7 @@
#include <id3tag.h> #include <id3tag.h>
#include <string> #include <string>
#include <stdexcept> #include <exception>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
@ -349,8 +349,8 @@ tag_id3_scan(InputStream &is,
tag = tag_id3_load(is); tag = tag_id3_load(is);
if (!tag) if (!tag)
return false; return false;
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
return false; return false;
} }

View File

@ -24,8 +24,6 @@
#include "util/StringBuffer.hxx" #include "util/StringBuffer.hxx"
#include "Compiler.h" #include "Compiler.h"
#include <stdexcept>
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
@ -83,7 +81,7 @@ FakeDecoder::Read(InputStream &is, void *buffer, size_t length)
{ {
try { try {
return is.LockRead(buffer, length); return is.LockRead(buffer, length);
} catch (const std::runtime_error &e) { } catch (...) {
return 0; return 0;
} }
} }

View File

@ -43,7 +43,7 @@ public:
try { try {
IcuConverter::Create("doesntexist"); IcuConverter::Create("doesntexist");
CPPUNIT_FAIL("Exception expected"); CPPUNIT_FAIL("Exception expected");
} catch (const std::runtime_error &) { } catch (...) {
} }
} }
@ -56,7 +56,7 @@ public:
try { try {
auto f = converter->FromUTF8(i); auto f = converter->FromUTF8(i);
CPPUNIT_FAIL("Exception expected"); CPPUNIT_FAIL("Exception expected");
} catch (const std::runtime_error &) { } catch (...) {
} }
} }

View File

@ -23,6 +23,8 @@
#include "event/Loop.hxx" #include "event/Loop.hxx"
#include "Log.hxx" #include "Log.hxx"
#include <exception>
#include <sys/inotify.h> #include <sys/inotify.h>
static constexpr unsigned IN_MASK = static constexpr unsigned IN_MASK =
@ -59,7 +61,7 @@ try {
event_loop.Run(); event_loop.Run();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
return EXIT_FAILURE; return EXIT_FAILURE;
} }

View File

@ -23,7 +23,7 @@
#include "net/SocketAddress.hxx" #include "net/SocketAddress.hxx"
#include "Log.hxx" #include "Log.hxx"
#include <stdexcept> #include <exception>
#ifdef _WIN32 #ifdef _WIN32
#include <ws2tcpip.h> #include <ws2tcpip.h>
@ -53,7 +53,7 @@ try {
freeaddrinfo(ai); freeaddrinfo(ai);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} catch (const std::runtime_error &e) { } catch (...) {
LogError(e); LogError(std::current_exception());
return EXIT_FAILURE; return EXIT_FAILURE;
} }