summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2016-09-05 12:05:54 +0200
committerMax Kellermann <max@musicpd.org>2016-09-09 15:16:47 +0200
commit6ed77f2a27c332218a7144606af90404ba433397 (patch)
tree7956e951258cbeff5e410dae5bc8689c50ca3304 /test
parenta73688a2be74ee6b5e68bfafa8d84e6cfe00bf5d (diff)
input/Plugin: migrate init() from class Error to C++ exceptions
Diffstat (limited to 'test')
-rw-r--r--test/dump_playlist.cxx6
-rw-r--r--test/dump_text_file.cxx12
-rw-r--r--test/read_tags.cxx13
-rw-r--r--test/run_decoder.cxx5
-rw-r--r--test/run_input.cxx12
-rw-r--r--test/visit_archive.cxx13
6 files changed, 31 insertions, 30 deletions
diff --git a/test/dump_playlist.cxx b/test/dump_playlist.cxx
index c3c869d86..1bb03b598 100644
--- a/test/dump_playlist.cxx
+++ b/test/dump_playlist.cxx
@@ -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();
diff --git a/test/dump_text_file.cxx b/test/dump_text_file.cxx
index 92ac64a12..7934349d6 100644
--- a/test/dump_text_file.cxx
+++ b/test/dump_text_file.cxx
@@ -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;
}
diff --git a/test/read_tags.cxx b/test/read_tags.cxx
index f95403fb0..17833516e 100644
--- a/test/read_tags.cxx
+++ b/test/read_tags.cxx
@@ -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;
}
diff --git a/test/run_decoder.cxx b/test/run_decoder.cxx
index 1d689a3d2..19abf0e7e 100644
--- a/test/run_decoder.cxx
+++ b/test/run_decoder.cxx
@@ -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();
diff --git a/test/run_input.cxx b/test/run_input.cxx
index 757895124..726758506 100644
--- a/test/run_input.cxx
+++ b/test/run_input.cxx
@@ -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;
}
diff --git a/test/visit_archive.cxx b/test/visit_archive.cxx
index 6b50867b5..96c2eb9d2 100644
--- a/test/visit_archive.cxx
+++ b/test/visit_archive.cxx
@@ -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;
}