config/ConfigFile: use std::exception on syntax error

This commit is contained in:
Max Kellermann
2015-12-16 11:12:30 +01:00
parent 6717325c3f
commit d256a0e98f
10 changed files with 127 additions and 87 deletions

View File

@@ -32,6 +32,7 @@
#include "tag/TagConfig.hxx"
#include "fs/Path.hxx"
#include "event/Loop.hxx"
#include "Log.hxx"
#include "util/Error.hxx"
#include <iostream>
@@ -89,7 +90,7 @@ DumpPlaylist(const PlaylistInfo &playlist,
int
main(int argc, char **argv)
{
try {
if (argc != 3) {
cerr << "Usage: DumpDatabase CONFIG PLUGIN" << endl;
return 1;
@@ -158,4 +159,7 @@ main(int argc, char **argv)
config_global_finish();
return EXIT_SUCCESS;
}
} catch (const std::exception &e) {
LogError(e);
return EXIT_FAILURE;
}

View File

@@ -48,7 +48,7 @@ tag_save(FILE *file, const Tag &tag)
}
int main(int argc, char **argv)
{
try {
const char *uri;
InputStream *is = NULL;
@@ -144,5 +144,8 @@ int main(int argc, char **argv)
input_stream_global_finish();
config_global_finish();
return 0;
}
return EXIT_SUCCESS;
} catch (const std::exception &e) {
LogError(e);
return EXIT_FAILURE;
}

View File

@@ -28,7 +28,7 @@
#include <stdlib.h>
int main(int argc, char **argv)
{
try {
if (argc != 3) {
fprintf(stderr, "Usage: read_conf FILE SETTING\n");
return EXIT_FAILURE;
@@ -60,4 +60,7 @@ int main(int argc, char **argv)
config_global_finish();
return ret;
}
} catch (const std::exception &e) {
LogError(e);
return EXIT_FAILURE;
}

View File

@@ -67,7 +67,7 @@ load_filter(const char *name)
}
int main(int argc, char **argv)
{
try {
struct audio_format_string af_string;
Error error2;
char buffer[4096];
@@ -151,5 +151,8 @@ int main(int argc, char **argv)
config_global_finish();
return 0;
}
return EXIT_SUCCESS;
} catch (const std::exception &e) {
LogError(e);
return EXIT_FAILURE;
}

View File

@@ -46,7 +46,7 @@ class MyNeighborListener final : public NeighborListener {
int
main(int argc, char **argv)
{
try {
if (argc != 2) {
fprintf(stderr, "Usage: run_neighbor_explorer CONFIG\n");
return EXIT_FAILURE;
@@ -82,4 +82,7 @@ main(int argc, char **argv)
loop.Run();
neighbor.Close();
return EXIT_SUCCESS;
}
} catch (const std::exception &e) {
LogError(e);
return EXIT_FAILURE;
}

View File

@@ -146,7 +146,7 @@ run_output(AudioOutput *ao, AudioFormat audio_format)
}
int main(int argc, char **argv)
{
try {
Error error;
if (argc < 3 || argc > 4) {
@@ -196,4 +196,7 @@ int main(int argc, char **argv)
config_global_finish();
return success ? EXIT_SUCCESS : EXIT_FAILURE;
}
} catch (const std::exception &e) {
LogError(e);
return EXIT_FAILURE;
}