db/Interface: migrate Update() from class Error to C++ exceptions

This commit is contained in:
Max Kellermann 2016-10-29 10:59:18 +02:00
parent df142d4f61
commit a2e3dc0592
3 changed files with 10 additions and 16 deletions

View File

@ -36,7 +36,6 @@
#include "ls.hxx"
#include "mixer/Volume.hxx"
#include "util/UriUtil.hxx"
#include "util/Error.hxx"
#include "util/StringAPI.hxx"
#include "fs/AllocatedPath.hxx"
#include "Stats.hxx"
@ -277,13 +276,10 @@ static CommandResult
handle_update(Response &r, Database &db,
const char *uri_utf8, bool discard)
{
Error error;
unsigned id = db.Update(uri_utf8, discard, error);
unsigned id = db.Update(uri_utf8, discard);
if (id > 0) {
r.Format("updating_db: %i\n", id);
return CommandResult::OK;
} else if (error.IsDefined()) {
return print_error(r, error);
} else {
/* Database::Update() has returned 0 without setting
the Error: the method is not implemented */

View File

@ -31,7 +31,6 @@ struct DatabasePlugin;
struct DatabaseStats;
struct DatabaseSelection;
struct LightSong;
class Error;
class Database {
const DatabasePlugin &plugin;
@ -111,14 +110,15 @@ public:
virtual DatabaseStats GetStats(const DatabaseSelection &selection) const = 0;
/**
* Update the database. Returns the job id on success, 0 on
* error (with #Error set) and 0 if not implemented (#Error
* not set).
* Update the database.
*
* Throws #std::runtime_error on error.
*
* @return the job id or 0 if not implemented
*/
virtual unsigned Update(gcc_unused const char *uri_utf8,
gcc_unused bool discard,
gcc_unused Error &error) {
/* not implemented: return 0 and don't set an Error */
gcc_unused bool discard) {
/* not implemented: return 0 */
return 0;
}

View File

@ -124,8 +124,7 @@ public:
DatabaseStats GetStats(const DatabaseSelection &selection) const override;
virtual unsigned Update(const char *uri_utf8, bool discard,
Error &error) override;
unsigned Update(const char *uri_utf8, bool discard) override;
virtual time_t GetUpdateStamp() const override {
return update_stamp;
@ -820,8 +819,7 @@ ProxyDatabase::GetStats(const DatabaseSelection &selection) const
}
unsigned
ProxyDatabase::Update(const char *uri_utf8, bool discard,
gcc_unused Error &error)
ProxyDatabase::Update(const char *uri_utf8, bool discard)
{
EnsureConnected();