aboutsummaryrefslogtreecommitdiff
path: root/build2/test/script/parser.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-01-06 03:24:33 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-01-09 21:44:22 +0300
commit9e2b4fd3bbc0c61bf6c84540c52869ec7d830718 (patch)
tree550c9edd5b29b164d7c8c2ac13111a9491495022 /build2/test/script/parser.cxx
parentc5d118cde064c09a416541a7f7e76d354552b2fd (diff)
Make use of operator<<(ostream, exception)
Diffstat (limited to 'build2/test/script/parser.cxx')
-rw-r--r--build2/test/script/parser.cxx30
1 files changed, 16 insertions, 14 deletions
diff --git a/build2/test/script/parser.cxx b/build2/test/script/parser.cxx
index f545896..e5f634c 100644
--- a/build2/test/script/parser.cxx
+++ b/build2/test/script/parser.cxx
@@ -3,7 +3,7 @@
// license : MIT; see accompanying LICENSE file
#include <sstream>
-#include <cstring> // strstr(), strchr()
+#include <cstring> // strstr()
#include <build2/test/script/parser>
@@ -26,20 +26,24 @@ namespace std
// resembles the following: 'regex_error(error_badrepeat): '. So we skip it.
//
static ostream&
- operator<< (ostream& os, const regex_error& e)
+ operator<< (ostream& o, const regex_error& e)
{
const char* d (e.what ());
- if (strchr (d, ' ') != nullptr)
- {
+
#if defined(_MSC_VER) && _MSC_VER <= 1910
- const char* s (strstr (d, "): "));
- if (s != nullptr)
- d = s + 3;
+ const char* rd (strstr (d, "): "));
+ if (rd != nullptr)
+ d = rd + 3;
#endif
- os << ": " << d;
- }
- return os;
+ ostringstream os;
+ os << runtime_error (d); // Purify the description.
+
+ string s (os.str ());
+ if (s.find (' ') != string::npos)
+ o << ": " << s;
+
+ return o;
}
}
@@ -77,8 +81,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail << "unable to read testscript " << p << ": " << e.what ()
- << endf;
+ fail << "unable to read testscript " << p << ": " << e << endf;
}
}
@@ -1054,8 +1057,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail (dl) << "unable to read testscript " << p << ": "
- << e.what ();
+ fail (dl) << "unable to read testscript " << p << ": " << e;
}
}
};