diff options
author | Max Kellermann <max@duempel.org> | 2016-03-19 00:13:57 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2016-03-19 00:19:50 +0100 |
commit | 2fd51826087897f2ce5bfd9ca27c1e167a3e4284 (patch) | |
tree | 2be6bbe1e4978ce4b8e9c7328e197477f1215575 /src/command | |
parent | 7ad7caa2ae6164615ddf28846b7e9e2cdc6e844f (diff) |
db/Interface: GetSong() throws exception on error
Diffstat (limited to 'src/command')
-rw-r--r-- | src/command/QueueCommands.cxx | 14 | ||||
-rw-r--r-- | src/command/StickerCommands.cxx | 19 |
2 files changed, 13 insertions, 20 deletions
diff --git a/src/command/QueueCommands.cxx b/src/command/QueueCommands.cxx index 5505bc329..fc0d244e6 100644 --- a/src/command/QueueCommands.cxx +++ b/src/command/QueueCommands.cxx @@ -41,17 +41,14 @@ #include <memory> #include <limits> -static CommandResult -AddUri(Client &client, const LocatedUri &uri, Response &r) +static void +AddUri(Client &client, const LocatedUri &uri) { - Error error; - std::unique_ptr<DetachedSong> song(SongLoader(client).LoadSong(uri, error)); - if (song == nullptr) - return print_error(r, error); + std::unique_ptr<DetachedSong> song(SongLoader(client).LoadSong(uri)); + assert(song); auto &partition = client.partition; partition.playlist.AppendSong(partition.pc, std::move(*song)); - return CommandResult::OK; } static CommandResult @@ -98,7 +95,8 @@ handle_add(Client &client, Request args, Response &r) case LocatedUri::Type::ABSOLUTE: case LocatedUri::Type::PATH: - return AddUri(client, located_uri, r); + AddUri(client, located_uri); + return CommandResult::OK; case LocatedUri::Type::RELATIVE: return AddDatabaseSelection(client, located_uri.canonical_uri, diff --git a/src/command/StickerCommands.cxx b/src/command/StickerCommands.cxx index 7fea154e0..5c4de3292 100644 --- a/src/command/StickerCommands.cxx +++ b/src/command/StickerCommands.cxx @@ -62,9 +62,7 @@ handle_sticker_song(Response &r, Partition &partition, Request args) /* get song song_id key */ if (args.size == 4 && StringIsEqual(cmd, "get")) { - const LightSong *song = db->GetSong(args[2], error); - if (song == nullptr) - return print_error(r, error); + const LightSong *song = db->GetSong(args[2]); const auto value = sticker_song_get_value(*song, args[3], error); @@ -82,9 +80,8 @@ handle_sticker_song(Response &r, Partition &partition, Request args) return CommandResult::OK; /* list song song_id */ } else if (args.size == 3 && StringIsEqual(cmd, "list")) { - const LightSong *song = db->GetSong(args[2], error); - if (song == nullptr) - return print_error(r, error); + const LightSong *song = db->GetSong(args[2]); + assert(song != nullptr); Sticker *sticker = sticker_song_get(*song, error); db->ReturnSong(song); @@ -97,9 +94,8 @@ handle_sticker_song(Response &r, Partition &partition, Request args) return CommandResult::OK; /* set song song_id id key */ } else if (args.size == 5 && StringIsEqual(cmd, "set")) { - const LightSong *song = db->GetSong(args[2], error); - if (song == nullptr) - return print_error(r, error); + const LightSong *song = db->GetSong(args[2]); + assert(song != nullptr); bool ret = sticker_song_set_value(*song, args[3], args[4], error); @@ -117,9 +113,8 @@ handle_sticker_song(Response &r, Partition &partition, Request args) /* delete song song_id [key] */ } else if ((args.size == 3 || args.size == 4) && StringIsEqual(cmd, "delete")) { - const LightSong *song = db->GetSong(args[2], error); - if (song == nullptr) - return print_error(r, error); + const LightSong *song = db->GetSong(args[2]); + assert(song != nullptr); bool ret = args.size == 3 ? sticker_song_delete(*song, error) |