From eb5f1bef76b8891136978513a5b2db92408e71c3 Mon Sep 17 00:00:00 2001 From: Arvin Schnell Date: Fri, 18 Dec 2015 15:42:50 +0100 Subject: [PATCH] - improved error message (see bsc#956606) --- package/snapper.changes | 5 +++++ snapper/AppUtil.h | 9 ++++++--- snapper/Btrfs.cc | 13 +++++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/package/snapper.changes b/package/snapper.changes index d0b8e1c4..93024e5e 100644 --- a/package/snapper.changes +++ b/package/snapper.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Fri Dec 18 15:41:16 CET 2015 - aschnell@suse.com + +- improved error message (see bsc#956606) + ------------------------------------------------------------------- Mon Dec 14 16:25:32 UTC 2015 - lslezak@suse.cz diff --git a/snapper/AppUtil.h b/snapper/AppUtil.h index c735a9df..d2211e77 100644 --- a/snapper/AppUtil.h +++ b/snapper/AppUtil.h @@ -116,10 +116,13 @@ namespace snapper struct runtime_error_with_errno : public std::runtime_error { - explicit runtime_error_with_errno(const char* what_arg, int errnum) - : runtime_error(sformat("%s, errno:%d (%s)", what_arg, errnum, - stringerror(errnum).c_str())) + explicit runtime_error_with_errno(const char* what_arg, int error_number) + : runtime_error(sformat("%s, errno:%d (%s)", what_arg, error_number, + stringerror(error_number).c_str())), + error_number(error_number) {} + + const int error_number; }; } diff --git a/snapper/Btrfs.cc b/snapper/Btrfs.cc index 9c222356..7029e66c 100644 --- a/snapper/Btrfs.cc +++ b/snapper/Btrfs.cc @@ -108,10 +108,19 @@ namespace snapper { create_subvolume(subvolume_dir.fd(), ".snapshots"); } - catch (const runtime_error& e) + catch (const runtime_error_with_errno& e) { y2err("create subvolume failed, " << e.what()); - throw CreateConfigFailedException("creating btrfs snapshot failed"); + + switch (e.error_number) + { + case EEXIST: + throw CreateConfigFailedException("creating btrfs subvolume .snapshots failed " + "since it already exists"); + + default: + throw CreateConfigFailedException("creating btrfs subvolume .snapshots failed"); + } } SFile x(subvolume_dir, ".snapshots"); -- 2.47.3