aboutsummaryrefslogtreecommitdiff
path: root/build2
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
parentc5d118cde064c09a416541a7f7e76d354552b2fd (diff)
Make use of operator<<(ostream, exception)
Diffstat (limited to 'build2')
-rw-r--r--build2/b.cxx2
-rw-r--r--build2/bin/init.cxx3
-rw-r--r--build2/cc/compile.cxx4
-rw-r--r--build2/cc/gcc.cxx2
-rw-r--r--build2/cc/link.cxx10
-rw-r--r--build2/cc/module.cxx2
-rw-r--r--build2/cc/windows-manifest.cxx2
-rw-r--r--build2/cc/windows-rpath.cxx8
-rw-r--r--build2/cli/init.cxx2
-rw-r--r--build2/cli/rule.cxx2
-rw-r--r--build2/config/operation.cxx4
-rw-r--r--build2/context.cxx2
-rw-r--r--build2/dist/operation.cxx6
-rw-r--r--build2/file.cxx6
-rw-r--r--build2/filesystem.cxx14
-rw-r--r--build2/filesystem.txx4
-rw-r--r--build2/function.cxx5
-rw-r--r--build2/install/rule.cxx20
-rw-r--r--build2/parser.cxx18
-rw-r--r--build2/pkgconfig/init.cxx2
-rw-r--r--build2/rule.cxx2
-rw-r--r--build2/test/rule.cxx2
-rw-r--r--build2/test/script/builtin.cxx25
-rw-r--r--build2/test/script/parser.cxx30
-rw-r--r--build2/test/script/runner.cxx36
-rw-r--r--build2/utility.cxx10
26 files changed, 112 insertions, 111 deletions
diff --git a/build2/b.cxx b/build2/b.cxx
index 7b9460b..bd77a02 100644
--- a/build2/b.cxx
+++ b/build2/b.cxx
@@ -201,7 +201,7 @@ main (int argc, char* argv[])
//
catch (const system_error& e)
{
- error << "pager failed: " << e.what ();
+ error << "pager failed: " << e;
return 1;
}
}
diff --git a/build2/bin/init.cxx b/build2/bin/init.cxx
index 89dea09..e1b812b 100644
--- a/build2/bin/init.cxx
+++ b/build2/bin/init.cxx
@@ -246,8 +246,7 @@ namespace build2
// This is where we suggest that the user specifies --config-sub
// to help us out.
//
- fail << "unable to parse binutils target '" << s << "': "
- << e.what () <<
+ fail << "unable to parse binutils target '" << s << "': " << e <<
info << "consider using the --config-sub option";
}
diff --git a/build2/cc/compile.cxx b/build2/cc/compile.cxx
index 1b34c69..6fd64c2 100644
--- a/build2/cc/compile.cxx
+++ b/build2/cc/compile.cxx
@@ -1370,7 +1370,7 @@ namespace build2
}
catch (const process_error& e)
{
- error << "unable to execute " << args[0] << ": " << e.what ();
+ error << "unable to execute " << args[0] << ": " << e;
// In a multi-threaded program that fork()'ed but did not exec(),
// it is unwise to try to do any kind of cleanup (like unwinding
@@ -1596,7 +1596,7 @@ namespace build2
}
catch (const process_error& e)
{
- error << "unable to execute " << args[0] << ": " << e.what ();
+ error << "unable to execute " << args[0] << ": " << e;
// In a multi-threaded program that fork()'ed but did not exec(),
// it is unwise to try to do any kind of cleanup (like unwinding
diff --git a/build2/cc/gcc.cxx b/build2/cc/gcc.cxx
index c778493..6ad1ad1 100644
--- a/build2/cc/gcc.cxx
+++ b/build2/cc/gcc.cxx
@@ -90,7 +90,7 @@ namespace build2
}
catch (const process_error& e)
{
- error << "unable to execute " << args[0] << ": " << e.what ();
+ error << "unable to execute " << args[0] << ": " << e;
if (e.child ())
exit (1);
diff --git a/build2/cc/link.cxx b/build2/cc/link.cxx
index f55013f..9dbfa36 100644
--- a/build2/cc/link.cxx
+++ b/build2/cc/link.cxx
@@ -978,12 +978,12 @@ namespace build2
{
if (pr.wait ()) // Ignore if child failed.
fail << "unable to pipe resource file to " << args[0]
- << ": " << e.what ();
+ << ": " << e;
}
}
catch (const process_error& e)
{
- error << "unable to execute " << args[0] << ": " << e.what ();
+ error << "unable to execute " << args[0] << ": " << e;
if (e.child ())
exit (1);
@@ -1498,7 +1498,7 @@ namespace build2
}
catch (const process_error& e)
{
- error << "unable to execute " << args[0] << ": " << e.what ();
+ error << "unable to execute " << args[0] << ": " << e;
// In a multi-threaded program that fork()'ed but did not exec(),
// it is unwise to try to do any kind of cleanup (like unwinding
@@ -1536,7 +1536,7 @@ namespace build2
}
catch (const process_error& e)
{
- error << "unable to execute " << args[0] << ": " << e.what ();
+ error << "unable to execute " << args[0] << ": " << e;
if (e.child ())
exit (1);
@@ -1577,7 +1577,7 @@ namespace build2
}
catch (const system_error& e)
{
- fail << "unable to create symlink " << l << ": " << e.what ();
+ fail << "unable to create symlink " << l << ": " << e;
}
};
diff --git a/build2/cc/module.cxx b/build2/cc/module.cxx
index 067aea3..40bd454 100644
--- a/build2/cc/module.cxx
+++ b/build2/cc/module.cxx
@@ -115,7 +115,7 @@ namespace build2
// help us out.
//
fail << "unable to parse " << x_lang << " compiler target '"
- << ci.target << "': " << e.what () <<
+ << ci.target << "': " << e <<
info << "consider using the --config-sub option";
}
}
diff --git a/build2/cc/windows-manifest.cxx b/build2/cc/windows-manifest.cxx
index c4e86e4..44d8f7b 100644
--- a/build2/cc/windows-manifest.cxx
+++ b/build2/cc/windows-manifest.cxx
@@ -127,7 +127,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail << "unable to write to " << m << ": " << e.what ();
+ fail << "unable to write to " << m << ": " << e;
}
return mf;
diff --git a/build2/cc/windows-rpath.cxx b/build2/cc/windows-rpath.cxx
index aa1d740..35d83cc 100644
--- a/build2/cc/windows-rpath.cxx
+++ b/build2/cc/windows-rpath.cxx
@@ -311,7 +311,7 @@ namespace build2
if (c != EPERM && c != ENOSYS)
{
print ("ln -s");
- fail << "unable to create symlink " << l << ": " << e.what ();
+ fail << "unable to create symlink " << l << ": " << e;
}
try
@@ -326,7 +326,7 @@ namespace build2
if (c != EPERM && c != ENOSYS)
{
print ("ln");
- fail << "unable to create hardlink " << l << ": " << e.what ();
+ fail << "unable to create hardlink " << l << ": " << e;
}
try
@@ -337,7 +337,7 @@ namespace build2
catch (const system_error& e)
{
print ("cp");
- fail << "unable to create copy " << l << ": " << e.what ();
+ fail << "unable to create copy " << l << ": " << e;
}
}
}
@@ -371,7 +371,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail << "unable to write to " << am << ": " << e.what ();
+ fail << "unable to write to " << am << ": " << e;
}
}
}
diff --git a/build2/cli/init.cxx b/build2/cli/init.cxx
index ead067a..45e2655 100644
--- a/build2/cli/init.cxx
+++ b/build2/cli/init.cxx
@@ -157,7 +157,7 @@ namespace build2
// found). So it would be good to redirect child's STDERR.
//
if (!optional)
- error << "unable to execute " << args[0] << ": " << e.what ();
+ error << "unable to execute " << args[0] << ": " << e;
if (e.child ())
exit (1);
diff --git a/build2/cli/rule.cxx b/build2/cli/rule.cxx
index 59a5d66..5b78723 100644
--- a/build2/cli/rule.cxx
+++ b/build2/cli/rule.cxx
@@ -301,7 +301,7 @@ namespace build2
}
catch (const process_error& e)
{
- error << "unable to execute " << args[0] << ": " << e.what ();
+ error << "unable to execute " << args[0] << ": " << e;
if (e.child ())
exit (1);
diff --git a/build2/config/operation.cxx b/build2/config/operation.cxx
index 7fdd682..3370c2c 100644
--- a/build2/config/operation.cxx
+++ b/build2/config/operation.cxx
@@ -57,7 +57,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail << "unable to write " << f << ": " << e.what ();
+ fail << "unable to write " << f << ": " << e;
}
}
@@ -277,7 +277,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail << "unable to write " << f << ": " << e.what ();
+ fail << "unable to write " << f << ": " << e;
}
}
diff --git a/build2/context.cxx b/build2/context.cxx
index 38c726d..106b7ec 100644
--- a/build2/context.cxx
+++ b/build2/context.cxx
@@ -299,7 +299,7 @@ namespace build2
}
catch (const invalid_argument& e)
{
- fail << "unable to parse build host '" << orig << "': " << e.what () <<
+ fail << "unable to parse build host '" << orig << "': " << e <<
info << "consider using the --config-guess option";
}
}
diff --git a/build2/dist/operation.cxx b/build2/dist/operation.cxx
index a662287..47e188c 100644
--- a/build2/dist/operation.cxx
+++ b/build2/dist/operation.cxx
@@ -338,7 +338,7 @@ namespace build2
}
catch (const process_error& e)
{
- error << "unable to execute " << args[0] << ": " << e.what ();
+ error << "unable to execute " << args[0] << ": " << e;
if (e.child ())
exit (1);
@@ -392,7 +392,7 @@ namespace build2
}
catch (const process_error& e)
{
- error << "unable to execute " << args[0] << ": " << e.what ();
+ error << "unable to execute " << args[0] << ": " << e;
if (e.child ())
exit (1);
@@ -444,7 +444,7 @@ namespace build2
}
catch (const process_error& e)
{
- error << "unable to execute " << args[0] << ": " << e.what ();
+ error << "unable to execute " << args[0] << ": " << e;
if (e.child ())
exit (1);
diff --git a/build2/file.cxx b/build2/file.cxx
index 83dcacf..cc1be77 100644
--- a/build2/file.cxx
+++ b/build2/file.cxx
@@ -107,7 +107,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail << "unable to read buildfile " << bf << ": " << e.what ();
+ fail << "unable to read buildfile " << bf << ": " << e;
}
}
@@ -307,7 +307,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail << "unable to read buildfile " << bf << ": " << e.what () << endf;
+ fail << "unable to read buildfile " << bf << ": " << e << endf;
}
// Never reached.
@@ -1087,7 +1087,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail (loc) << "unable to read buildfile " << es << ": " << e.what ();
+ fail (loc) << "unable to read buildfile " << es << ": " << e;
}
return names (); // Never reached.
diff --git a/build2/filesystem.cxx b/build2/filesystem.cxx
index 798f002..86bdff8 100644
--- a/build2/filesystem.cxx
+++ b/build2/filesystem.cxx
@@ -28,7 +28,7 @@ namespace build2
if (verb >= v)
text << "mkdir " << d;
- fail << "unable to create directory " << d << ": " << e.what () << endf;
+ fail << "unable to create directory " << d << ": " << e << endf;
}
if (ms == mkdir_status::success)
@@ -57,7 +57,7 @@ namespace build2
if (verb >= v)
text << "mkdir -p " << d;
- fail << "unable to create directory " << d << ": " << e.what () << endf;
+ fail << "unable to create directory " << d << ": " << e << endf;
}
if (ms == mkdir_status::success)
@@ -89,7 +89,7 @@ namespace build2
}
catch (const system_error& e)
{
- fail << "unable to remove directory " << d << ": " << e.what ();
+ fail << "unable to remove directory " << d << ": " << e;
}
return rmdir_status::success;
@@ -104,7 +104,7 @@ namespace build2
}
catch (const system_error& e)
{
- fail << "unable to stat path " << f << ": " << e.what () << endf;
+ fail << "unable to stat path " << f << ": " << e << endf;
}
}
@@ -117,7 +117,7 @@ namespace build2
}
catch (const system_error& e)
{
- fail << "unable to stat path " << d << ": " << e.what () << endf;
+ fail << "unable to stat path " << d << ": " << e << endf;
}
}
@@ -130,7 +130,7 @@ namespace build2
}
catch (const system_error& e)
{
- fail << "unable to stat path " << p << ": " << e.what () << endf;
+ fail << "unable to stat path " << p << ": " << e << endf;
}
}
@@ -143,7 +143,7 @@ namespace build2
}
catch (const system_error& e)
{
- fail << "unable to scan directory " << d << ": " << e.what () << endf;
+ fail << "unable to scan directory " << d << ": " << e << endf;
}
}
}
diff --git a/build2/filesystem.txx b/build2/filesystem.txx
index 5a4838e..708c75e 100644
--- a/build2/filesystem.txx
+++ b/build2/filesystem.txx
@@ -37,7 +37,7 @@ namespace build2
catch (const system_error& e)
{
print ();
- error << "unable to remove file " << f << ": " << e.what ();
+ error << "unable to remove file " << f << ": " << e;
throw failed ();
}
@@ -78,7 +78,7 @@ namespace build2
catch (const system_error& e)
{
print ();
- error << "unable to remove directory " << d << ": " << e.what ();
+ error << "unable to remove directory " << d << ": " << e;
throw failed ();
}
diff --git a/build2/function.cxx b/build2/function.cxx
index c3a08c1..eeb332f 100644
--- a/build2/function.cxx
+++ b/build2/function.cxx
@@ -249,9 +249,8 @@ namespace build2
diag_record dr (fail);
dr << "invalid argument";
- const char* w (e.what ());
- if (*w != '\0')
- dr << ": " << w;
+ if (*e.what () != '\0')
+ dr << ": " << e;
dr << endf;
}
diff --git a/build2/install/rule.cxx b/build2/install/rule.cxx
index 1c21a1c..a368ac9 100644
--- a/build2/install/rule.cxx
+++ b/build2/install/rule.cxx
@@ -425,7 +425,7 @@ namespace build2
}
catch (const system_error& e)
{
- fail << "invalid installation directory " << d << ": " << e.what ();
+ fail << "invalid installation directory " << d << ": " << e;
}
// While install -d will create all the intermediate components between
@@ -477,7 +477,7 @@ namespace build2
}
catch (const process_error& e)
{
- error << "unable to execute " << args[0] << ": " << e.what ();
+ error << "unable to execute " << args[0] << ": " << e;
if (e.child ())
exit (1);
@@ -543,7 +543,7 @@ namespace build2
}
catch (const process_error& e)
{
- error << "unable to execute " << args[0] << ": " << e.what ();
+ error << "unable to execute " << args[0] << ": " << e;
if (e.child ())
exit (1);
@@ -592,7 +592,7 @@ namespace build2
}
catch (const process_error& e)
{
- error << "unable to execute " << args[0] << ": " << e.what ();
+ error << "unable to execute " << args[0] << ": " << e;
if (e.child ())
exit (1);
@@ -690,7 +690,7 @@ namespace build2
}
catch (const system_error& e)
{
- fail << "invalid installation directory " << d << ": " << e.what ();
+ fail << "invalid installation directory " << d << ": " << e;
}
if (r)
@@ -718,7 +718,7 @@ namespace build2
}
catch (const system_error& e)
{
- fail << "unable to remove directory " << d << ": " << e.what ();
+ fail << "unable to remove directory " << d << ": " << e;
}
}
else
@@ -748,7 +748,7 @@ namespace build2
}
catch (const process_error& e)
{
- error << "unable to execute " << args[0] << ": " << e.what ();
+ error << "unable to execute " << args[0] << ": " << e;
if (e.child ())
exit (1);
@@ -791,7 +791,7 @@ namespace build2
}
catch (const system_error& e)
{
- fail << "invalid installation path " << f << ": " << e.what ();
+ fail << "invalid installation path " << f << ": " << e;
}
path relf (relative (f));
@@ -818,7 +818,7 @@ namespace build2
}
catch (const system_error& e)
{
- fail << "unable to remove file " << f << ": " << e.what ();
+ fail << "unable to remove file " << f << ": " << e;
}
}
else
@@ -847,7 +847,7 @@ namespace build2
}
catch (const process_error& e)
{
- error << "unable to execute " << args[0] << ": " << e.what ();
+ error << "unable to execute " << args[0] << ": " << e;
if (e.child ())
exit (1);
diff --git a/build2/parser.cxx b/build2/parser.cxx
index d01b6fe..57a5618 100644
--- a/build2/parser.cxx
+++ b/build2/parser.cxx
@@ -820,7 +820,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail (l) << "unable to read buildfile " << p << ": " << e.what ();
+ fail (l) << "unable to read buildfile " << p << ": " << e;
}
}
@@ -956,7 +956,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail (l) << "unable to read buildfile " << p << ": " << e.what ();
+ fail (l) << "unable to read buildfile " << p << ": " << e;
}
scope_ = ocs;
@@ -1214,7 +1214,7 @@ namespace build2
try {iv = to_version (v);}
catch (const invalid_argument& e)
{
- fail (l) << "invalid version '" << v << "': " << e.what () << endf;
+ fail (l) << "invalid version '" << v << "': " << e << endf;
}
if (iv > BUILD2_VERSION)
@@ -1329,7 +1329,7 @@ namespace build2
take = (k.back () == '!' ? !e : e);
}
- catch (const invalid_argument& e) { fail (l) << e.what (); }
+ catch (const invalid_argument& e) { fail (l) << e; }
}
}
else
@@ -1433,7 +1433,7 @@ namespace build2
return;
}
}
- catch (const invalid_argument& e) { fail (el) << e.what (); }
+ catch (const invalid_argument& e) { fail (el) << e; }
// Being here means things didn't end up well. Parse the description, if
// any, with expansion. Then fail.
@@ -1798,7 +1798,7 @@ namespace build2
{
q = pp ? true : convert<bool> (move (lhs));
}
- catch (const invalid_argument& e) { fail (l) << e.what () << endf; }
+ catch (const invalid_argument& e) { fail (l) << e << endf; }
if (!pp)
pre_parse_ = !q; // Short-circuit middle?
@@ -1852,7 +1852,7 @@ namespace build2
//
lhs = convert<bool> (move (rhs));
}
- catch (const invalid_argument& e) { fail (l) << e.what (); }
+ catch (const invalid_argument& e) { fail (l) << e; }
}
pre_parse_ = pp;
@@ -1892,7 +1892,7 @@ namespace build2
//
lhs = convert<bool> (move (rhs));
}
- catch (const invalid_argument& e) { fail (l) << e.what (); }
+ catch (const invalid_argument& e) { fail (l) << e; }
}
pre_parse_ = pp;
@@ -2005,7 +2005,7 @@ namespace build2
//
v = !convert<bool> (move (v));
}
- catch (const invalid_argument& e) { fail (l) << e.what (); }
+ catch (const invalid_argument& e) { fail (l) << e; }
break;
}
default:
diff --git a/build2/pkgconfig/init.cxx b/build2/pkgconfig/init.cxx
index 7149eb6..8d50def 100644
--- a/build2/pkgconfig/init.cxx
+++ b/build2/pkgconfig/init.cxx
@@ -72,7 +72,7 @@ namespace build2
}
catch (const process_error& e)
{
- fail << "unable to execute " << x << ": " << e.what ();
+ fail << "unable to execute " << x << ": " << e;
}
}
diff --git a/build2/rule.cxx b/build2/rule.cxx
index 433814e..a9b7c4e 100644
--- a/build2/rule.cxx
+++ b/build2/rule.cxx
@@ -226,7 +226,7 @@ namespace build2
}
catch (const system_error& e)
{
- fail << "unable to create directory " << d << ": " << e.what ();
+ fail << "unable to create directory " << d << ": " << e;
}
ts |= target_state::changed;
diff --git a/build2/test/rule.cxx b/build2/test/rule.cxx
index ccbf932..4201f37 100644
--- a/build2/test/rule.cxx
+++ b/build2/test/rule.cxx
@@ -498,7 +498,7 @@ namespace build2
}
catch (const process_error& e)
{
- error << "unable to execute " << args[0] << ": " << e.what ();
+ error << "unable to execute " << args[0] << ": " << e;
if (e.child ())
exit (1);
diff --git a/build2/test/script/builtin.cxx b/build2/test/script/builtin.cxx
index 0b99e8f..d00a8a1 100644
--- a/build2/test/script/builtin.cxx
+++ b/build2/test/script/builtin.cxx
@@ -161,7 +161,7 @@ namespace build2
else
cerr << "'" << p << "'";
- cerr << ": " << e.what () << endl;
+ cerr << ": " << e << endl;
throw failed ();
}
@@ -179,7 +179,7 @@ namespace build2
catch (const io_error& e)
{
if (cerr.good ())
- cerr << "cat: " << e.what () << endl;
+ cerr << "cat: " << e << endl;
}
catch (const failed&)
{
@@ -222,7 +222,7 @@ namespace build2
}
catch (const std::exception& e)
{
- cerr << "echo: " << e.what () << endl;
+ cerr << "echo: " << e << endl;
}
cerr.close ();
@@ -338,7 +338,7 @@ namespace build2
catch (const system_error& e)
{
cerr << "mkdir: unable to create directory '" << p << "': "
- << e.what () << endl;
+ << e << endl;
throw failed ();
}
}
@@ -355,7 +355,7 @@ namespace build2
catch (const io_error& e)
{
if (cerr.good ())
- cerr << "mkdir: " << e.what () << endl;
+ cerr << "mkdir: " << e << endl;
}
catch (const failed&)
{
@@ -478,8 +478,7 @@ namespace build2
}
catch (const system_error& e)
{
- cerr << "rm: unable to remove '" << p << "': " << e.what ()
- << endl;
+ cerr << "rm: unable to remove '" << p << "': " << e << endl;
throw failed ();
}
}
@@ -496,7 +495,7 @@ namespace build2
catch (const io_error& e)
{
if (cerr.good ())
- cerr << "rm: " << e.what () << endl;
+ cerr << "rm: " << e << endl;
}
catch (const failed&)
{
@@ -578,8 +577,8 @@ namespace build2
}
catch (const io_error& e)
{
- cerr << "touch: cannot create file '" << p << "': "
- << e.what () << endl;
+ cerr << "touch: cannot create file '" << p << "': " << e
+ << endl;
throw failed ();
}
@@ -594,8 +593,8 @@ namespace build2
}
catch (const system_error& e)
{
- cerr << "touch: cannot create/update '" << p << "': "
- << e.what () << endl;
+ cerr << "touch: cannot create/update '" << p << "': " << e
+ << endl;
throw failed ();
}
}
@@ -612,7 +611,7 @@ namespace build2
catch (const io_error& e)
{
if (cerr.good ())
- cerr << "touch: " << e.what () << endl;
+ cerr << "touch: " << e << endl;
}
catch (const failed&)
{
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;
}
}
};
diff --git a/build2/test/script/runner.cxx b/build2/test/script/runner.cxx
index cbf0de0..64c6e87 100644
--- a/build2/test/script/runner.cxx
+++ b/build2/test/script/runner.cxx
@@ -41,7 +41,7 @@ namespace build2
// executed let's add the location anyway to ease the
// troubleshooting. And let's stick to that principle down the road.
//
- fail (ll) << "unable to read " << p << ": " << e.what () << endf;
+ fail (ll) << "unable to read " << p << ": " << e << endf;
}
}
@@ -91,7 +91,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail (ll) << "unable to read " << p << ": " << e.what ();
+ fail (ll) << "unable to read " << p << ": " << e;
}
}
}
@@ -151,7 +151,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail (ll) << "unable to write " << opp << ": " << e.what ();
+ fail (ll) << "unable to write " << opp << ": " << e;
}
auto output_info = [&what, &ll] (diag_record& d,
@@ -203,6 +203,9 @@ namespace build2
//
// ...: Invalid data.\r\r\n
//
+ // Note that our custom operator<<(ostream&, const exception&)
+ // removes this junk.
+ //
while (!s.empty () && s.back () == '\r')
s.pop_back ();
@@ -211,7 +214,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail (ll) << "unable to read " << op << ": " << e.what ();
+ fail (ll) << "unable to read " << op << ": " << e;
}
if (regex_match (ls, rd.regex.regex)) // Doesn't throw.
@@ -263,7 +266,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail (ll) << "unable to write " << ep << ": " << e.what ();
+ fail (ll) << "unable to write " << ep << ": " << e;
}
// Diff utility prints the differences to stdout. But for the
@@ -293,7 +296,7 @@ namespace build2
}
catch (const process_error& e)
{
- error (ll) << "unable to execute " << pp << ": " << e.what ();
+ error (ll) << "unable to execute " << pp << ": " << e;
if (e.child ())
exit (1);
@@ -506,7 +509,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail (ll) << "unable to read " << isp << ": " << e.what ();
+ fail (ll) << "unable to read " << isp << ": " << e;
}
};
@@ -521,7 +524,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail (ll) << "unable to duplicate stdin: " << e.what ();
+ fail (ll) << "unable to duplicate stdin: " << e;
}
break;
@@ -556,7 +559,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail (ll) << "unable to write to null device: " << e.what ();
+ fail (ll) << "unable to write to null device: " << e;
}
break;
@@ -587,7 +590,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail (ll) << "unable to write " << isp << ": " << e.what ();
+ fail (ll) << "unable to write " << isp << ": " << e;
}
open_stdin ();
@@ -639,8 +642,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail (ll) << "unable to duplicate " << what << ": "
- << e.what ();
+ fail (ll) << "unable to duplicate " << what << ": " << e;
}
return dfd;
@@ -658,7 +660,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail (ll) << "unable to write to null device: " << e.what ();
+ fail (ll) << "unable to write to null device: " << e;
}
return -2;
@@ -699,7 +701,7 @@ namespace build2
}
catch (const io_error& e)
{
- fail (ll) << "unable to write " << p << ": " << e.what ();
+ fail (ll) << "unable to write " << p << ": " << e;
}
return fd.get ();
@@ -729,7 +731,7 @@ namespace build2
catch (const io_error& e)
{
fail (ll) << "unable to duplicate " << (mo ? "stderr" : "stdout")
- << ": " << e.what ();
+ << ": " << e;
}
}
@@ -750,7 +752,7 @@ namespace build2
catch (const system_error& e)
{
fail (ll) << "unable to execute " << c.program << " builtin: "
- << e.what ();
+ << e;
}
}
else
@@ -788,7 +790,7 @@ namespace build2
}
catch (const process_error& e)
{
- error (ll) << "unable to execute " << pp << ": " << e.what ();
+ error (ll) << "unable to execute " << pp << ": " << e;
if (e.child ())
std::exit (1);
diff --git a/build2/utility.cxx b/build2/utility.cxx
index cf7e867..76d3367 100644
--- a/build2/utility.cxx
+++ b/build2/utility.cxx
@@ -160,7 +160,7 @@ namespace build2
}
catch (const process_error& e)
{
- fail << "unable to execute " << args0 << ": " << e.what () << endf;
+ fail << "unable to execute " << args0 << ": " << e << endf;
}
process_path
@@ -171,7 +171,7 @@ namespace build2
}
catch (const process_error& e)
{
- fail << "unable to execute " << f << ": " << e.what () << endf;
+ fail << "unable to execute " << f << ": " << e << endf;
}
process
@@ -192,11 +192,11 @@ namespace build2
{
// Note: run_finish() expects this exact message.
//
- cerr << "unable to execute " << args[0] << ": " << e.what () << endl;
+ cerr << "unable to execute " << args[0] << ": " << e << endl;
exit (1);
}
else
- fail << "unable to execute " << args[0] << ": " << e.what () << endf;
+ fail << "unable to execute " << args[0] << ": " << e << endf;
}
}
@@ -225,7 +225,7 @@ namespace build2
}
catch (const process_error& e)
{
- fail << "unable to execute " << args[0] << ": " << e.what () << endf;
+ fail << "unable to execute " << args[0] << ": " << e << endf;
}
const string empty_string;