input/Plugin: migrate init() from class Error to C++ exceptions
This commit is contained in:
@@ -68,11 +68,7 @@ try {
|
||||
|
||||
const ScopeIOThread io_thread;
|
||||
|
||||
if (!input_stream_global_init(error)) {
|
||||
LogError(error);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
input_stream_global_init();
|
||||
playlist_list_global_init();
|
||||
decoder_plugin_init_all();
|
||||
|
||||
|
@@ -31,6 +31,8 @@
|
||||
#include "archive/ArchiveList.hxx"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -63,7 +65,7 @@ dump_input_stream(InputStreamPtr &&is)
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
try {
|
||||
int ret;
|
||||
|
||||
if (argc != 2) {
|
||||
@@ -82,10 +84,7 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
Error error;
|
||||
if (!input_stream_global_init(error)) {
|
||||
LogError(error);
|
||||
return 2;
|
||||
}
|
||||
input_stream_global_init();
|
||||
|
||||
/* open the stream and dump it */
|
||||
|
||||
@@ -116,4 +115,7 @@ int main(int argc, char **argv)
|
||||
config_global_finish();
|
||||
|
||||
return ret;
|
||||
} catch (const std::exception &e) {
|
||||
LogError(e);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
@@ -31,6 +31,8 @@
|
||||
#include "thread/Cond.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include <assert.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
@@ -68,7 +70,7 @@ static constexpr TagHandler print_handler = {
|
||||
};
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
try {
|
||||
const char *decoder_name;
|
||||
const struct DecoderPlugin *plugin;
|
||||
|
||||
@@ -88,11 +90,7 @@ int main(int argc, char **argv)
|
||||
const ScopeIOThread io_thread;
|
||||
|
||||
Error error;
|
||||
if (!input_stream_global_init(error)) {
|
||||
LogError(error);
|
||||
return 2;
|
||||
}
|
||||
|
||||
input_stream_global_init();
|
||||
decoder_plugin_init_all();
|
||||
|
||||
plugin = decoder_plugin_from_name(decoder_name);
|
||||
@@ -129,4 +127,7 @@ int main(int argc, char **argv)
|
||||
ScanGenericTags(path, print_handler, nullptr);
|
||||
|
||||
return 0;
|
||||
} catch (const std::exception &e) {
|
||||
LogError(e);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
@@ -50,10 +50,7 @@ try {
|
||||
const ScopeIOThread io_thread;
|
||||
|
||||
Error error;
|
||||
if (!input_stream_global_init(error)) {
|
||||
LogError(error);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
input_stream_global_init();
|
||||
|
||||
decoder_plugin_init_all();
|
||||
|
||||
|
@@ -34,6 +34,8 @@
|
||||
#include "archive/ArchiveList.hxx"
|
||||
#endif
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -91,7 +93,7 @@ dump_input_stream(InputStream *is)
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
try {
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage: run_input URI\n");
|
||||
return EXIT_FAILURE;
|
||||
@@ -108,10 +110,7 @@ int main(int argc, char **argv)
|
||||
#endif
|
||||
|
||||
Error error;
|
||||
if (!input_stream_global_init(error)) {
|
||||
LogError(error);
|
||||
return 2;
|
||||
}
|
||||
input_stream_global_init();
|
||||
|
||||
/* open the stream and dump it */
|
||||
|
||||
@@ -142,4 +141,7 @@ int main(int argc, char **argv)
|
||||
config_global_finish();
|
||||
|
||||
return ret;
|
||||
} catch (const std::exception &e) {
|
||||
LogError(e);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
@@ -28,6 +28,9 @@
|
||||
#include "archive/ArchiveVisitor.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
@@ -42,7 +45,7 @@ class MyArchiveVisitor final : public ArchiveVisitor {
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
try {
|
||||
Error error;
|
||||
|
||||
if (argc != 3) {
|
||||
@@ -61,10 +64,7 @@ main(int argc, char **argv)
|
||||
|
||||
archive_plugin_init_all();
|
||||
|
||||
if (!input_stream_global_init(error)) {
|
||||
fprintf(stderr, "%s", error.GetMessage());
|
||||
return 2;
|
||||
}
|
||||
input_stream_global_init();
|
||||
|
||||
/* open the archive and dump it */
|
||||
|
||||
@@ -95,4 +95,7 @@ main(int argc, char **argv)
|
||||
config_global_finish();
|
||||
|
||||
return result;
|
||||
} catch (const std::exception &e) {
|
||||
LogError(e);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
Reference in New Issue
Block a user