From 8fab56680c3ba5618eda05a95c62cad3c1481773 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Thu, 13 Aug 2015 12:57:07 +0100 Subject: [PATCH] [all tools] Improve the error message if opening the metadata fails. Remind the admin that you shouldn't run the tools on live data. --- persistent-data/block.tcc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/persistent-data/block.tcc b/persistent-data/block.tcc index d21caad..6e47a91 100644 --- a/persistent-data/block.tcc +++ b/persistent-data/block.tcc @@ -46,14 +46,23 @@ namespace { // to exception.h void syscall_failed(char const *call) { ostringstream out; - out << "syscall '" << call << "' failed: " << base::error_string(errno);; + out << "syscall '" << call << "' failed: " << base::error_string(errno); + throw runtime_error(out.str()); + } + + void syscall_failed(string const &call, string const &message) + { + ostringstream out; + out << "syscall '" << call << "' failed: " << base::error_string(errno) << "\n" + << message; throw runtime_error(out.str()); } int open_file(string const &path, int flags) { int fd = ::open(path.c_str(), OPEN_FLAGS | flags, DEFAULT_MODE); if (fd < 0) - syscall_failed("open"); + syscall_failed("open", + "Note: you cannot run this tool with these options on live metadata."); return fd; }