LocateUri: migrate from class Error to C++ exceptions

This commit is contained in:
Max Kellermann
2016-10-27 21:59:17 +02:00
parent 726fc53e62
commit 6961bd61ca
16 changed files with 74 additions and 132 deletions

View File

@@ -35,8 +35,6 @@
#endif
#endif
class Domain;
class Error;
class Client;
#ifdef ENABLE_DATABASE
@@ -45,11 +43,6 @@ class Storage;
struct LocatedUri {
enum class Type {
/**
* Failed to parse the URI.
*/
UNKNOWN,
/**
* An absolute URI with a supported scheme.
*/
@@ -76,22 +69,13 @@ struct LocatedUri {
LocatedUri(Type _type, const char *_uri,
AllocatedPath &&_path=AllocatedPath::Null())
:type(_type), canonical_uri(_uri), path(std::move(_path)) {}
gcc_const
static LocatedUri Unknown() {
return LocatedUri(Type::UNKNOWN, nullptr);
}
bool IsUnknown() const {
return type == Type::UNKNOWN;
}
};
extern const Domain locate_uri_domain;
/**
* Classify a URI.
*
* Throws #std::runtime_error on error.
*
* @param client the #Client that is used to determine whether a local
* file is allowed; nullptr disables the check and allows all local
* files
@@ -100,10 +84,10 @@ extern const Domain locate_uri_domain;
* that feature is disabled if this parameter is nullptr
*/
LocatedUri
LocateUri(const char *uri, const Client *client,
LocateUri(const char *uri, const Client *client
#ifdef ENABLE_DATABASE
const Storage *storage,
, const Storage *storage
#endif
Error &error);
);
#endif