]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- improved error message 824/head
authorArvin Schnell <aschnell@suse.de>
Wed, 12 Jul 2023 07:27:12 +0000 (09:27 +0200)
committerArvin Schnell <aschnell@suse.de>
Wed, 12 Jul 2023 07:27:12 +0000 (09:27 +0200)
LIBVERSION
client/errors.cc
client/snapper.cc
server/Client.cc
snapper/Exception.h
snapper/Snapper.cc

index 9fe9ff9d996b339374d1d060c6195ce7dbd53be7..a3fcc7121bbab0e2221463e4493d1454f1b67252 100644 (file)
@@ -1 +1 @@
-7.0.1
+7.1.0
index a38b85d098d87c46a9293175c6930de3ba605a09..bda684e3a9ebe2a75628fe3cb10a52ef66ed79d6 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) [2011-2014] Novell, Inc.
- * Copyright (c) [2016-2021] SUSE LLC
+ * Copyright (c) [2016-2023] SUSE LLC
  *
  * All Rights Reserved.
  *
@@ -102,10 +102,10 @@ error_description(const DBus::ErrorException& e)
        return _("Deleting snapshot failed.");
 
     if (name == "error.invalid_user")
-       return _("Invalid user.");
+       return sformat(_("Invalid user (%s)."), e.message());
 
     if (name == "error.invalid_group")
-       return _("Invalid group.");
+       return sformat(_("Invalid group (%s)."), e.message());
 
     if (name == "error.acl_error")
        return _("ACL error.");
index 0381ac03aadd207fa7d0c9ff2005b0cfac57669d..3ddebe1e0bfdb581747983423894ce9e820e0b04 100644 (file)
@@ -298,13 +298,13 @@ main(int argc, char** argv)
        catch (const InvalidUserException& e)
        {
            SN_CAUGHT(e);
-           cerr << _("Invalid user.") << endl;
+           cerr << sformat(_("Invalid user (%s)."), e.what()) << endl;
            exit(EXIT_FAILURE);
        }
        catch (const InvalidGroupException& e)
        {
            SN_CAUGHT(e);
-           cerr << _("Invalid group.") << endl;
+           cerr << sformat(_("Invalid group (%s)."), e.what()) << endl;
            exit(EXIT_FAILURE);
        }
        catch (const QuotaException& e)
index b71c1cbeea4cc0f2b5da1c81e6007016cc5d4a09..c117c03506d71e07fc7ff267f72e0af70b66b628 100644 (file)
@@ -1987,13 +1987,13 @@ Client::dispatch(DBus::Connection& conn, DBus::Message& msg)
     catch (const InvalidUserException& e)
     {
        SN_CAUGHT(e);
-       DBus::MessageError reply(msg, "error.invalid_user", DBUS_ERROR_FAILED);
+       DBus::MessageError reply(msg, "error.invalid_user", e.what());
        conn.send(reply);
     }
     catch (const InvalidGroupException& e)
     {
        SN_CAUGHT(e);
-       DBus::MessageError reply(msg, "error.invalid_group", DBUS_ERROR_FAILED);
+       DBus::MessageError reply(msg, "error.invalid_group", e.what());
        conn.send(reply);
     }
     catch (const QuotaException& e)
index a9be41925a322d4fb4d17cfc79412b1d4ab026c1..04f1c438d43e4045e254f658b0b09205e0f07c2d 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) [2011-2014] Novell, Inc.
- * Copyright (c) [2015,2018] SUSE LLC
+ * Copyright (c) [2015-2023] SUSE LLC
  *
  * All Rights Reserved.
  *
@@ -386,17 +386,21 @@ namespace snapper
 
     struct InvalidUserException : public Exception
     {
-       explicit InvalidUserException() : Exception("invalid user") {}
+       explicit InvalidUserException() __attribute__((deprecated)) : Exception("invalid user") {}
+       explicit InvalidUserException(const std::string& user) : Exception("invalid user '" + user + "'") {}
+       // TODO save user
     };
 
     struct InvalidGroupException : public Exception
     {
-       explicit InvalidGroupException() : Exception("invalid group") {}
+       explicit InvalidGroupException() __attribute__((deprecated)) : Exception("invalid group") {}
+       explicit InvalidGroupException(const std::string& group) : Exception("invalid group '" + group + "'") {}
+       // TODO save group
     };
 
     struct UnsupportedException : public Exception
     {
-        explicit UnsupportedException() : Exception("unsupported") {}
+       explicit UnsupportedException() : Exception("unsupported") {}
     };
 
 }
index 85ba0966d3b85f37a038efbaee53d036cc91e04a..7d20068bbea32a0e565e52a16b75fbf2cafba6cc 100644 (file)
@@ -554,11 +554,11 @@ namespace snapper
        vector<string> users;
        if (config_info->get_value(KEY_ALLOW_USERS, users))
        {
-           for (vector<string>::const_iterator it = users.begin(); it != users.end(); ++it)
+           for (const string& user : users)
            {
                uid_t uid;
-               if (!get_user_uid(it->c_str(), uid))
-                   SN_THROW(InvalidUserException());
+               if (!get_user_uid(user.c_str(), uid))
+                   SN_THROW(InvalidUserException(user));
                uids.push_back(uid);
            }
        }
@@ -567,11 +567,11 @@ namespace snapper
        vector<string> groups;
        if (config_info->get_value(KEY_ALLOW_GROUPS, groups))
        {
-           for (vector<string>::const_iterator it = groups.begin(); it != groups.end(); ++it)
+           for (const string& group : groups)
            {
                gid_t gid;
-               if (!get_group_gid(it->c_str(), gid))
-                   SN_THROW(InvalidGroupException());
+               if (!get_group_gid(group.c_str(), gid))
+                   SN_THROW(InvalidGroupException(group));
                gids.push_back(gid);
            }
        }