db/simple/Save: migrate from class Error to C++ exceptions

This commit is contained in:
Max Kellermann
2016-10-29 09:45:34 +02:00
parent dea46e8d5a
commit 90a14e14f4
11 changed files with 95 additions and 166 deletions

View File

@@ -27,8 +27,7 @@
#include "tag/Tag.hxx"
#include "tag/TagBuilder.hxx"
#include "util/StringUtil.hxx"
#include "util/Error.hxx"
#include "util/Domain.hxx"
#include "util/RuntimeError.hxx"
#include <string.h>
#include <stdlib.h>
@@ -36,8 +35,6 @@
#define SONG_MTIME "mtime"
#define SONG_END "song_end"
static constexpr Domain song_save_domain("song_save");
static void
range_save(BufferedOutputStream &os, unsigned start_ms, unsigned end_ms)
{
@@ -74,8 +71,7 @@ song_save(BufferedOutputStream &os, const DetachedSong &song)
}
DetachedSong *
song_load(TextFile &file, const char *uri,
Error &error)
song_load(TextFile &file, const char *uri)
{
DetachedSong *song = new DetachedSong(uri);
@@ -88,9 +84,7 @@ song_load(TextFile &file, const char *uri,
if (colon == nullptr || colon == line) {
delete song;
error.Format(song_save_domain,
"unknown line in db: %s", line);
return nullptr;
throw FormatRuntimeError("unknown line in db: %s", line);
}
*colon++ = 0;
@@ -118,9 +112,7 @@ song_load(TextFile &file, const char *uri,
} else {
delete song;
error.Format(song_save_domain,
"unknown line in db: %s", line);
return nullptr;
throw FormatRuntimeError("unknown line in db: %s", line);
}
}