db/Interface: migrate visitor methods from class Error to C++ exceptions
This commit is contained in:
@@ -156,35 +156,27 @@ handle_playlistclear(gcc_unused Client &client,
|
||||
}
|
||||
|
||||
CommandResult
|
||||
handle_playlistadd(Client &client, Request args, Response &r)
|
||||
handle_playlistadd(Client &client, Request args, gcc_unused Response &r)
|
||||
{
|
||||
const char *const playlist = args[0];
|
||||
const char *const uri = args[1];
|
||||
|
||||
bool success;
|
||||
Error error;
|
||||
if (uri_has_scheme(uri)) {
|
||||
const SongLoader loader(client);
|
||||
spl_append_uri(playlist, loader, uri);
|
||||
success = true;
|
||||
} else {
|
||||
#ifdef ENABLE_DATABASE
|
||||
const Database &db = client.GetDatabaseOrThrow();
|
||||
|
||||
success = search_add_to_playlist(db, *client.GetStorage(),
|
||||
uri, playlist, nullptr,
|
||||
error);
|
||||
search_add_to_playlist(db, *client.GetStorage(),
|
||||
uri, playlist, nullptr);
|
||||
#else
|
||||
success = false;
|
||||
r.Error(ACK_ERROR_NO_EXIST, "directory or file not found");
|
||||
return CommandResult::ERROR;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (!success && !error.IsDefined()) {
|
||||
r.Error(ACK_ERROR_NO_EXIST, "directory or file not found");
|
||||
return CommandResult::ERROR;
|
||||
}
|
||||
|
||||
return success ? CommandResult::OK : print_error(r, error);
|
||||
return CommandResult::OK;
|
||||
}
|
||||
|
||||
CommandResult
|
||||
|
Reference in New Issue
Block a user