conf: show line number in error message
authorMax Kellermann <max@musicpd.org>
Sun, 8 Sep 2019 20:01:21 +0000 (22:01 +0200)
committerMax Kellermann <max@musicpd.org>
Sun, 8 Sep 2019 20:08:11 +0000 (22:08 +0200)
src/conf.cxx

index 40d8644..3e50805 100644 (file)
@@ -647,8 +647,10 @@ read_rc_file(const char *filename)
                return false;
        }
 
+       unsigned no = 0;
        char line[MAX_LINE_LENGTH];
        while (fgets(line, sizeof(line), file) != nullptr) {
+               ++no;
                char *p = StripLeft(line);
 
                if (*p != 0 && *p != COMMENT_TOKEN) {
@@ -657,6 +659,9 @@ read_rc_file(const char *filename)
                        try {
                                parse_line(p);
                        } catch (...) {
+                               fprintf(stderr,
+                                       "Failed to parse '%s' line %u: ",
+                                       filename, no);
                                PrintException(std::current_exception());
                        }
                }