diff options
author | Max Kellermann <max@musicpd.org> | 2016-10-29 09:45:34 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2016-10-29 09:45:34 +0200 |
commit | 90a14e14f457e7ec34dd8ff3dcfe710e2dd93208 (patch) | |
tree | d12ec940506c2a51fee437e5499ea248a99b7650 /src/PlaylistDatabase.cxx | |
parent | dea46e8d5a714a483aee8e14775eb8b3a69aa4ad (diff) |
db/simple/Save: migrate from class Error to C++ exceptions
Diffstat (limited to 'src/PlaylistDatabase.cxx')
-rw-r--r-- | src/PlaylistDatabase.cxx | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/src/PlaylistDatabase.cxx b/src/PlaylistDatabase.cxx index c0f756fc8..71b554db2 100644 --- a/src/PlaylistDatabase.cxx +++ b/src/PlaylistDatabase.cxx @@ -23,14 +23,11 @@ #include "fs/io/TextFile.hxx" #include "fs/io/BufferedOutputStream.hxx" #include "util/StringUtil.hxx" -#include "util/Error.hxx" -#include "util/Domain.hxx" +#include "util/RuntimeError.hxx" #include <string.h> #include <stdlib.h> -static constexpr Domain playlist_database_domain("playlist_database"); - void playlist_vector_save(BufferedOutputStream &os, const PlaylistVector &pv) { @@ -41,9 +38,8 @@ playlist_vector_save(BufferedOutputStream &os, const PlaylistVector &pv) pi.name.c_str(), (long)pi.mtime); } -bool -playlist_metadata_load(TextFile &file, PlaylistVector &pv, const char *name, - Error &error) +void +playlist_metadata_load(TextFile &file, PlaylistVector &pv, const char *name) { PlaylistInfo pm(name, 0); @@ -53,24 +49,19 @@ playlist_metadata_load(TextFile &file, PlaylistVector &pv, const char *name, while ((line = file.ReadLine()) != nullptr && strcmp(line, "playlist_end") != 0) { colon = strchr(line, ':'); - if (colon == nullptr || colon == line) { - error.Format(playlist_database_domain, - "unknown line in db: %s", line); - return false; - } + if (colon == nullptr || colon == line) + throw FormatRuntimeError("unknown line in db: %s", + line); *colon++ = 0; value = StripLeft(colon); if (strcmp(line, "mtime") == 0) pm.mtime = strtol(value, nullptr, 10); - else { - error.Format(playlist_database_domain, - "unknown line in db: %s", line); - return false; - } + else + throw FormatRuntimeError("unknown line in db: %s", + line); } pv.UpdateOrInsert(std::move(pm)); - return true; } |