aboutsummaryrefslogtreecommitdiffstats
path: root/src/ConfigPath.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-08-10 18:02:44 +0200
committerMax Kellermann <max@duempel.org>2013-09-04 18:14:22 +0200
commit29030b54c98b0aee65fbc10ebf7ba36bed98c02c (patch)
tree79766830b55ebca38ddbce84d8d548227eedb69e /src/ConfigPath.cxx
parentc9fcc7f14860777458153eb2d13c773ccfa1daa2 (diff)
downloadmpd-29030b54c98b0aee65fbc10ebf7ba36bed98c02c.tar.gz
mpd-29030b54c98b0aee65fbc10ebf7ba36bed98c02c.tar.xz
mpd-29030b54c98b0aee65fbc10ebf7ba36bed98c02c.zip
util/Error: new error passing library
Replaces GLib's GError.
Diffstat (limited to 'src/ConfigPath.cxx')
-rw-r--r--src/ConfigPath.cxx36
1 files changed, 16 insertions, 20 deletions
diff --git a/src/ConfigPath.cxx b/src/ConfigPath.cxx
index b90956a2a..9c5945a32 100644
--- a/src/ConfigPath.cxx
+++ b/src/ConfigPath.cxx
@@ -20,6 +20,8 @@
#include "config.h"
#include "ConfigPath.hxx"
#include "fs/Path.hxx"
+#include "util/Error.hxx"
+#include "util/Domain.hxx"
#include "conf.h"
#include <glib.h>
@@ -46,31 +48,25 @@
#include <windows.h>
#endif
-gcc_const
-static inline GQuark
-parse_path_quark(void)
-{
- return g_quark_from_static_string("path");
-}
+static constexpr Domain path_domain("path");
Path
-ParsePath(const char *path, GError **error_r)
+ParsePath(const char *path, Error &error)
{
assert(path != nullptr);
- assert(error_r == nullptr || *error_r == nullptr);
Path path2 = Path::FromUTF8(path);
if (path2.IsNull()) {
- g_set_error(error_r, parse_path_quark(), 0,
- "Failed to convert path to file system charset: %s",
- path);
+ error.Format(path_domain,
+ "Failed to convert path to file system charset: %s",
+ path);
return Path::Null();
}
#ifndef WIN32
if (!g_path_is_absolute(path) && path[0] != '~') {
- g_set_error(error_r, parse_path_quark(), 0,
- "not an absolute path: %s", path);
+ error.Format(path_domain,
+ "not an absolute path: %s", path);
return Path::Null();
} else if (path[0] == '~') {
const char *home;
@@ -80,8 +76,8 @@ ParsePath(const char *path, GError **error_r)
if (user != nullptr) {
struct passwd *passwd = getpwnam(user);
if (!passwd) {
- g_set_error(error_r, parse_path_quark(), 0,
- "no such user: %s", user);
+ error.Format(path_domain,
+ "no such user: %s", user);
return Path::Null();
}
@@ -89,9 +85,9 @@ ParsePath(const char *path, GError **error_r)
} else {
home = g_get_home_dir();
if (home == nullptr) {
- g_set_error_literal(error_r, parse_path_quark(), 0,
- "problems getting home "
- "for current user");
+ error.Set(path_domain,
+ "problems getting home "
+ "for current user");
return Path::Null();
}
}
@@ -107,8 +103,8 @@ ParsePath(const char *path, GError **error_r)
struct passwd *passwd = getpwnam(user);
if (!passwd) {
- g_set_error(error_r, parse_path_quark(), 0,
- "no such user: %s", user);
+ error.Format(path_domain,
+ "no such user: %s", user);
g_free(user);
return Path::Null();
}