LocateUri: migrate from class Error to C++ exceptions
This commit is contained in:
@@ -21,7 +21,6 @@
|
||||
#include "CommandError.hxx"
|
||||
#include "PlaylistError.hxx"
|
||||
#include "db/DatabaseError.hxx"
|
||||
#include "LocateUri.hxx"
|
||||
#include "client/Response.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "Log.hxx"
|
||||
@@ -89,8 +88,6 @@ ToAck(const Error &error)
|
||||
{
|
||||
if (error.IsDomain(ack_domain)) {
|
||||
return (enum ack)error.GetCode();
|
||||
} else if (error.IsDomain(locate_uri_domain)) {
|
||||
return ACK_ERROR_ARG;
|
||||
} else if (error.IsDomain(errno_domain)) {
|
||||
return ACK_ERROR_SYSTEM;
|
||||
}
|
||||
|
@@ -216,16 +216,12 @@ handle_read_comments(Client &client, Request args, Response &r)
|
||||
|
||||
const char *const uri = args.front();
|
||||
|
||||
Error error;
|
||||
const auto located_uri = LocateUri(uri, &client,
|
||||
const auto located_uri = LocateUri(uri, &client
|
||||
#ifdef ENABLE_DATABASE
|
||||
nullptr,
|
||||
, nullptr
|
||||
#endif
|
||||
error);
|
||||
);
|
||||
switch (located_uri.type) {
|
||||
case LocatedUri::Type::UNKNOWN:
|
||||
return print_error(r, error);
|
||||
|
||||
case LocatedUri::Type::ABSOLUTE:
|
||||
return read_stream_comments(r, located_uri.canonical_uri);
|
||||
|
||||
|
@@ -123,17 +123,13 @@ handle_listfiles(Client &client, Request args, Response &r)
|
||||
/* default is root directory */
|
||||
const auto uri = args.GetOptional(0, "");
|
||||
|
||||
Error error;
|
||||
const auto located_uri = LocateUri(uri, &client,
|
||||
const auto located_uri = LocateUri(uri, &client
|
||||
#ifdef ENABLE_DATABASE
|
||||
nullptr,
|
||||
, nullptr
|
||||
#endif
|
||||
error);
|
||||
);
|
||||
|
||||
switch (located_uri.type) {
|
||||
case LocatedUri::Type::UNKNOWN:
|
||||
return print_error(r, error);
|
||||
|
||||
case LocatedUri::Type::ABSOLUTE:
|
||||
#ifdef ENABLE_DATABASE
|
||||
/* use storage plugin to list remote directory */
|
||||
@@ -238,17 +234,13 @@ handle_lsinfo(Client &client, Request args, Response &r)
|
||||
compatibility, work around this here */
|
||||
uri = "";
|
||||
|
||||
Error error;
|
||||
const auto located_uri = LocateUri(uri, &client,
|
||||
const auto located_uri = LocateUri(uri, &client
|
||||
#ifdef ENABLE_DATABASE
|
||||
nullptr,
|
||||
, nullptr
|
||||
#endif
|
||||
error);
|
||||
);
|
||||
|
||||
switch (located_uri.type) {
|
||||
case LocatedUri::Type::UNKNOWN:
|
||||
return print_error(r, error);
|
||||
|
||||
case LocatedUri::Type::ABSOLUTE:
|
||||
return handle_lsinfo_absolute(r, located_uri.canonical_uri);
|
||||
|
||||
|
@@ -165,7 +165,8 @@ handle_playlistadd(Client &client, Request args, Response &r)
|
||||
Error error;
|
||||
if (uri_has_scheme(uri)) {
|
||||
const SongLoader loader(client);
|
||||
success = spl_append_uri(playlist, loader, uri, error);
|
||||
spl_append_uri(playlist, loader, uri);
|
||||
success = true;
|
||||
} else {
|
||||
#ifdef ENABLE_DATABASE
|
||||
const Database &db = client.GetDatabaseOrThrow();
|
||||
|
@@ -83,16 +83,12 @@ handle_add(Client &client, Request args, Response &r)
|
||||
here */
|
||||
uri = "";
|
||||
|
||||
Error error;
|
||||
const auto located_uri = LocateUri(uri, &client,
|
||||
const auto located_uri = LocateUri(uri, &client
|
||||
#ifdef ENABLE_DATABASE
|
||||
nullptr,
|
||||
, nullptr
|
||||
#endif
|
||||
error);
|
||||
);
|
||||
switch (located_uri.type) {
|
||||
case LocatedUri::Type::UNKNOWN:
|
||||
return print_error(r, error);
|
||||
|
||||
case LocatedUri::Type::ABSOLUTE:
|
||||
case LocatedUri::Type::PATH:
|
||||
AddUri(client, located_uri);
|
||||
@@ -112,10 +108,7 @@ handle_addid(Client &client, Request args, Response &r)
|
||||
const char *const uri = args.front();
|
||||
|
||||
const SongLoader loader(client);
|
||||
Error error;
|
||||
unsigned added_id = client.partition.AppendURI(loader, uri, error);
|
||||
if (added_id == 0)
|
||||
return print_error(r, error);
|
||||
unsigned added_id = client.partition.AppendURI(loader, uri);
|
||||
|
||||
if (args.size == 2) {
|
||||
unsigned to = args.ParseUnsigned(1);
|
||||
|
Reference in New Issue
Block a user