From 5d9a889190c7ab531eff4d6cb74cb4e3a58f32a7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 8 Sep 2016 20:26:40 +0200 Subject: [PATCH] decoder/Thread: throw C++ exceptions on error --- src/decoder/DecoderThread.cxx | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/decoder/DecoderThread.cxx b/src/decoder/DecoderThread.cxx index e55b2ab69..89c222bdf 100644 --- a/src/decoder/DecoderThread.cxx +++ b/src/decoder/DecoderThread.cxx @@ -415,19 +415,16 @@ decoder_run_song(DecoderControl &dc, if (decoder.error.IsDefined()) { /* copy the Error from struct Decoder to DecoderControl */ - dc.state = DecoderState::ERROR; - dc.error = std::make_exception_ptr(std::move(decoder.error)); + throw std::move(decoder.error); } else if (success) dc.state = DecoderState::STOP; else { - dc.state = DecoderState::ERROR; - const char *error_uri = song.GetURI(); const std::string allocated = uri_remove_auth(error_uri); if (!allocated.empty()) error_uri = allocated.c_str(); - dc.error = std::make_exception_ptr(FormatRuntimeError("Failed to decode %s", error_uri)); + throw FormatRuntimeError("Failed to decode %s", error_uri); } dc.client_cond.signal(); @@ -453,10 +450,8 @@ try { Error error; path_buffer = AllocatedPath::FromUTF8(uri_utf8, error); if (path_buffer.IsNull()) { - dc.state = DecoderState::ERROR; - dc.error = std::make_exception_ptr(std::move(error)); dc.CommandFinishedLocked(); - return; + throw std::move(error); } path_fs = path_buffer;