Commit a2e3dc05 authored by Max Kellermann's avatar Max Kellermann

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

parent df142d4f
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include "ls.hxx" #include "ls.hxx"
#include "mixer/Volume.hxx" #include "mixer/Volume.hxx"
#include "util/UriUtil.hxx" #include "util/UriUtil.hxx"
#include "util/Error.hxx"
#include "util/StringAPI.hxx" #include "util/StringAPI.hxx"
#include "fs/AllocatedPath.hxx" #include "fs/AllocatedPath.hxx"
#include "Stats.hxx" #include "Stats.hxx"
...@@ -277,13 +276,10 @@ static CommandResult ...@@ -277,13 +276,10 @@ static CommandResult
handle_update(Response &r, Database &db, handle_update(Response &r, Database &db,
const char *uri_utf8, bool discard) const char *uri_utf8, bool discard)
{ {
Error error; unsigned id = db.Update(uri_utf8, discard);
unsigned id = db.Update(uri_utf8, discard, error);
if (id > 0) { if (id > 0) {
r.Format("updating_db: %i\n", id); r.Format("updating_db: %i\n", id);
return CommandResult::OK; return CommandResult::OK;
} else if (error.IsDefined()) {
return print_error(r, error);
} else { } else {
/* Database::Update() has returned 0 without setting /* Database::Update() has returned 0 without setting
the Error: the method is not implemented */ the Error: the method is not implemented */
......
...@@ -31,7 +31,6 @@ struct DatabasePlugin; ...@@ -31,7 +31,6 @@ struct DatabasePlugin;
struct DatabaseStats; struct DatabaseStats;
struct DatabaseSelection; struct DatabaseSelection;
struct LightSong; struct LightSong;
class Error;
class Database { class Database {
const DatabasePlugin &plugin; const DatabasePlugin &plugin;
...@@ -111,14 +110,15 @@ public: ...@@ -111,14 +110,15 @@ public:
virtual DatabaseStats GetStats(const DatabaseSelection &selection) const = 0; virtual DatabaseStats GetStats(const DatabaseSelection &selection) const = 0;
/** /**
* Update the database. Returns the job id on success, 0 on * Update the database.
* error (with #Error set) and 0 if not implemented (#Error *
* not set). * Throws #std::runtime_error on error.
*
* @return the job id or 0 if not implemented
*/ */
virtual unsigned Update(gcc_unused const char *uri_utf8, virtual unsigned Update(gcc_unused const char *uri_utf8,
gcc_unused bool discard, gcc_unused bool discard) {
gcc_unused Error &error) { /* not implemented: return 0 */
/* not implemented: return 0 and don't set an Error */
return 0; return 0;
} }
......
...@@ -124,8 +124,7 @@ public: ...@@ -124,8 +124,7 @@ public:
DatabaseStats GetStats(const DatabaseSelection &selection) const override; DatabaseStats GetStats(const DatabaseSelection &selection) const override;
virtual unsigned Update(const char *uri_utf8, bool discard, unsigned Update(const char *uri_utf8, bool discard) override;
Error &error) override;
virtual time_t GetUpdateStamp() const override { virtual time_t GetUpdateStamp() const override {
return update_stamp; return update_stamp;
...@@ -820,8 +819,7 @@ ProxyDatabase::GetStats(const DatabaseSelection &selection) const ...@@ -820,8 +819,7 @@ ProxyDatabase::GetStats(const DatabaseSelection &selection) const
} }
unsigned unsigned
ProxyDatabase::Update(const char *uri_utf8, bool discard, ProxyDatabase::Update(const char *uri_utf8, bool discard)
gcc_unused Error &error)
{ {
EnsureConnected(); EnsureConnected();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment