Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/atf/dist/atf-sh fix the open error messages to ...



details:   https://anonhg.NetBSD.org/src/rev/c5f6888702cd
branches:  trunk
changeset: 812197:c5f6888702cd
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Dec 04 01:43:58 2015 +0000

description:
fix the open error messages to include the right file and strerror

diffstat:

 external/bsd/atf/dist/atf-sh/atf-check.cpp |  17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diffs (48 lines):

diff -r 423c54cf62f7 -r c5f6888702cd external/bsd/atf/dist/atf-sh/atf-check.cpp
--- a/external/bsd/atf/dist/atf-sh/atf-check.cpp        Fri Dec 04 01:42:47 2015 +0000
+++ b/external/bsd/atf/dist/atf-sh/atf-check.cpp        Fri Dec 04 01:43:58 2015 +0000
@@ -359,11 +359,20 @@
 
 static
 void
+open_error(const atf::fs::path& path)
+{
+    throw std::runtime_error("Failed to open " + path.str() + " "
+       + ::strerror(errno));
+}
+       
+
+static
+void
 cat_file(const atf::fs::path& path)
 {
     std::ifstream stream(path.c_str());
     if (!stream)
-        throw std::runtime_error("Failed to open " + path.str());
+       open_error(path);
 
     stream >> std::noskipws;
     std::istream_iterator< char > begin(stream), end;
@@ -379,7 +388,7 @@
 {
     std::ifstream stream(path.c_str());
     if (!stream)
-        throw std::runtime_error("Failed to open " + path.str());
+       open_error(path);
 
     bool found = false;
 
@@ -410,11 +419,11 @@
 
     std::ifstream f1(p1.c_str());
     if (!f1)
-        throw std::runtime_error("Failed to open " + p1.str());
+       open_error(p1);
 
     std::ifstream f2(p2.c_str());
     if (!f2)
-        throw std::runtime_error("Failed to open " + p1.str());
+       open_error(p2);
 
     for (;;) {
         char buf1[512], buf2[512];



Home | Main Index | Thread Index | Old Index