Commit 5d9a8891 authored by Max Kellermann's avatar Max Kellermann

decoder/Thread: throw C++ exceptions on error

parent a9acc9c9
...@@ -415,19 +415,16 @@ decoder_run_song(DecoderControl &dc, ...@@ -415,19 +415,16 @@ decoder_run_song(DecoderControl &dc,
if (decoder.error.IsDefined()) { if (decoder.error.IsDefined()) {
/* copy the Error from struct Decoder to /* copy the Error from struct Decoder to
DecoderControl */ DecoderControl */
dc.state = DecoderState::ERROR; throw std::move(decoder.error);
dc.error = std::make_exception_ptr(std::move(decoder.error));
} else if (success) } else if (success)
dc.state = DecoderState::STOP; dc.state = DecoderState::STOP;
else { else {
dc.state = DecoderState::ERROR;
const char *error_uri = song.GetURI(); const char *error_uri = song.GetURI();
const std::string allocated = uri_remove_auth(error_uri); const std::string allocated = uri_remove_auth(error_uri);
if (!allocated.empty()) if (!allocated.empty())
error_uri = allocated.c_str(); 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(); dc.client_cond.signal();
...@@ -453,10 +450,8 @@ try { ...@@ -453,10 +450,8 @@ try {
Error error; Error error;
path_buffer = AllocatedPath::FromUTF8(uri_utf8, error); path_buffer = AllocatedPath::FromUTF8(uri_utf8, error);
if (path_buffer.IsNull()) { if (path_buffer.IsNull()) {
dc.state = DecoderState::ERROR;
dc.error = std::make_exception_ptr(std::move(error));
dc.CommandFinishedLocked(); dc.CommandFinishedLocked();
return; throw std::move(error);
} }
path_fs = path_buffer; path_fs = path_buffer;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment