input/Plugin: migrate open() from class Error to C++ exceptions
This commit is contained in:
@@ -44,13 +44,7 @@ try {
|
||||
if (!playlist_suffix_supported(suffix_utf8.c_str()))
|
||||
return nullptr;
|
||||
|
||||
Error error;
|
||||
auto is = OpenLocalInputStream(path, mutex, cond, error);
|
||||
if (is == nullptr) {
|
||||
LogError(error);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto is = OpenLocalInputStream(path, mutex, cond);
|
||||
return playlist_list_open_stream_suffix(std::move(is),
|
||||
suffix_utf8.c_str());
|
||||
} catch (const std::runtime_error &e) {
|
||||
@@ -85,15 +79,7 @@ try {
|
||||
if (playlist != nullptr)
|
||||
return playlist;
|
||||
|
||||
Error error;
|
||||
auto is = InputStream::OpenReady(uri, mutex, cond, error);
|
||||
if (is == nullptr) {
|
||||
if (error.IsDefined())
|
||||
FormatError(error, "Failed to open %s", uri);
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto is = InputStream::OpenReady(uri, mutex, cond);
|
||||
return playlist_list_open_stream(std::move(is), uri);
|
||||
} catch (const std::runtime_error &e) {
|
||||
LogError(e);
|
||||
|
||||
@@ -230,15 +230,9 @@ static constexpr yajl_callbacks parse_callbacks = {
|
||||
static int
|
||||
soundcloud_parse_json(const char *url, yajl_handle hand,
|
||||
Mutex &mutex, Cond &cond)
|
||||
{
|
||||
try {
|
||||
Error error;
|
||||
auto input_stream = InputStream::OpenReady(url, mutex, cond,
|
||||
error);
|
||||
if (input_stream == nullptr) {
|
||||
if (error.IsDefined())
|
||||
LogError(error);
|
||||
return -1;
|
||||
}
|
||||
auto input_stream = InputStream::OpenReady(url, mutex, cond);
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
|
||||
@@ -275,6 +269,9 @@ soundcloud_parse_json(const char *url, yajl_handle hand,
|
||||
}
|
||||
|
||||
return 0;
|
||||
} catch (const std::exception &e) {
|
||||
LogError(e);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user