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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -330,7 +330,7 @@ oggflac_decode(DecoderClient &client, InputStream &input_stream)
moved it */
try {
input_stream.LockRewind();
} catch (const std::runtime_error &) {
} catch (...) {
}
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;
return 0;
#endif
} catch (const std::runtime_error &) {
} catch (...) {
/* just some random non-zero errno value */
errno = EINVAL;
return 0;
@@ -96,8 +96,8 @@ FlacIOSeek(FLAC__IOHandle handle, FLAC__int64 _offset, int whence)
try {
is->LockSeek(offset);
return 0;
} catch (const std::runtime_error &e) {
LogError(e);
} catch (...) {
LogError(std::current_exception());
return -1;
}
}

View File

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

View File

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

View File

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

View File

@@ -22,7 +22,7 @@
#include "lib/xiph/OggFind.hxx"
#include "input/InputStream.hxx"
#include <stdexcept>
#include <exception>
/**
* 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 */
try {
input_stream.LockSeek(old_offset);
} catch (const std::runtime_error &) {
} catch (...) {
}
return result;

View File

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

View File

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

View File

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

View File

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

View File

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