aboutsummaryrefslogtreecommitdiff
path: root/build2
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2017-03-22 00:44:52 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2017-03-22 00:44:52 +0300
commitadddeca028100355a922cc4e45226ce7f18420c9 (patch)
treee056441415e76531c7b1137264b9238ac8056c05 /build2
parent330820504e2f231b9e0255142147e2b7939bce0b (diff)
Make use of throw_generic_error()
Diffstat (limited to 'build2')
-rw-r--r--build2/b.cxx2
-rw-r--r--build2/cc/windows-rpath.cxx8
-rw-r--r--build2/scheduler.cxx2
-rw-r--r--build2/scheduler.txx2
-rw-r--r--build2/test/script/builtin.cxx12
-rw-r--r--build2/test/script/runner.cxx4
-rw-r--r--build2/utility2
7 files changed, 21 insertions, 11 deletions
diff --git a/build2/b.cxx b/build2/b.cxx
index 60ac2f0..89c3d9c 100644
--- a/build2/b.cxx
+++ b/build2/b.cxx
@@ -104,7 +104,7 @@ main (int argc, char* argv[])
#ifndef _WIN32
if (signal (SIGPIPE, SIG_IGN) == SIG_ERR)
fail << "unable to ignore broken pipe (SIGPIPE) signal: "
- << system_error (errno, system_category ()); // Sanitize.
+ << system_error (errno, generic_category ()); // Sanitize.
#endif
// Parse the command line. We want to be able to specify options, vars,
diff --git a/build2/cc/windows-rpath.cxx b/build2/cc/windows-rpath.cxx
index 383663f..0b34963 100644
--- a/build2/cc/windows-rpath.cxx
+++ b/build2/cc/windows-rpath.cxx
@@ -315,6 +315,10 @@ namespace build2
}
catch (const system_error& e)
{
+ // Make sure that the error denotes errno portable code.
+ //
+ assert (e.code ().category () == generic_category ());
+
int c (e.code ().value ());
if (c != EPERM && c != ENOSYS)
@@ -330,6 +334,10 @@ namespace build2
}
catch (const system_error& e)
{
+ // Make sure the error reflects errno portable code.
+ //
+ assert (e.code ().category () == generic_category ());
+
int c (e.code ().value ());
if (c != EPERM && c != ENOSYS)
diff --git a/build2/scheduler.cxx b/build2/scheduler.cxx
index 9a3003b..a453cb3 100644
--- a/build2/scheduler.cxx
+++ b/build2/scheduler.cxx
@@ -100,7 +100,7 @@ namespace build2
ready_--;
if (shutdown_)
- throw system_error (ECANCELED, system_category ());
+ throw_generic_error (ECANCELED);
active_++;
}
diff --git a/build2/scheduler.txx b/build2/scheduler.txx
index 684409c..b62acdb 100644
--- a/build2/scheduler.txx
+++ b/build2/scheduler.txx
@@ -38,7 +38,7 @@ namespace build2
lock ql (tq->mutex);
if (tq->shutdown)
- throw system_error (ECANCELED, std::system_category ());
+ throw_generic_error (ECANCELED);
if (task_data* td = push (*tq))
{
diff --git a/build2/test/script/builtin.cxx b/build2/test/script/builtin.cxx
index 5b011e3..6f63551 100644
--- a/build2/test/script/builtin.cxx
+++ b/build2/test/script/builtin.cxx
@@ -307,7 +307,7 @@ namespace build2
try
{
if (try_mkdir (to) == mkdir_status::already_exists)
- throw system_error (EEXIST, system_category ());
+ throw_generic_error (EEXIST);
if (cleanup)
sp.clean ({cleanup_type::always, to}, true);
@@ -628,7 +628,7 @@ namespace build2
sp.clean ({cleanup_type::always, p}, true);
}
else // == mkdir_status::already_exists
- throw system_error (EEXIST, system_category ());
+ throw_generic_error (EEXIST);
}
catch (const system_error& e)
{
@@ -748,7 +748,7 @@ namespace build2
try_rmdir_r (d);
}
else if (try_rmfile (p) == rmfile_status::not_exist && !force)
- throw system_error (ENOENT, system_category ());
+ throw_generic_error (ENOENT);
}
catch (const system_error& e)
{
@@ -848,9 +848,9 @@ namespace build2
rmdir_status s (try_rmdir (p));
if (s == rmdir_status::not_empty)
- throw system_error (ENOTEMPTY, system_category ());
+ throw_generic_error (ENOTEMPTY);
else if (s == rmdir_status::not_exist && !force)
- throw system_error (ENOENT, system_category ());
+ throw_generic_error (ENOENT);
}
catch (const system_error& e)
{
@@ -1304,7 +1304,7 @@ namespace build2
#else
if (_utime (p.string ().c_str (), nullptr) == -1)
#endif
- throw system_error (errno, system_category ());
+ throw_generic_error (errno);
}
else if (!entry_exists (p))
{
diff --git a/build2/test/script/runner.cxx b/build2/test/script/runner.cxx
index 464c1f9..3c5f8ba 100644
--- a/build2/test/script/runner.cxx
+++ b/build2/test/script/runner.cxx
@@ -1171,7 +1171,7 @@ namespace build2
if (ifd.get () == -1) // @@ TMP
throw io_error (
- error_code (errno, system_category ()).message ());
+ error_code (errno, generic_category ()).message ());
}
catch (const io_error& e)
{
@@ -1296,7 +1296,7 @@ namespace build2
if (fd.get () == -1) // @@ TMP
throw io_error (
- error_code (errno, system_category ()).message ());
+ error_code (errno, generic_category ()).message ());
}
catch (const io_error& e)
{
diff --git a/build2/utility b/build2/utility
index 0c129c4..2880bb5 100644
--- a/build2/utility
+++ b/build2/utility
@@ -60,6 +60,8 @@ namespace build2
using butl::exception_guard;
using butl::make_exception_guard;
+ using butl::throw_generic_error;
+
// Basic string utilities.
//