From 8b69cab7c802a0d0bd9cc90da33002dd5f86042f Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Thu, 15 Sep 2016 16:26:23 +0300 Subject: Add io_error alias for std::ios_base::failure --- bpkg/archive.cxx | 2 +- bpkg/auth.cxx | 17 ++++++++--------- bpkg/cfg-create.cxx | 6 +++--- bpkg/checksum.cxx | 10 +++++----- bpkg/fetch.cxx | 10 +++++----- bpkg/help.cxx | 4 ++-- bpkg/pkg-verify.cxx | 4 ++-- bpkg/rep-create.cxx | 3 +-- bpkg/rep-info.cxx | 2 +- bpkg/satisfaction.cxx | 2 +- bpkg/types | 2 ++ 11 files changed, 31 insertions(+), 31 deletions(-) (limited to 'bpkg') diff --git a/bpkg/archive.cxx b/bpkg/archive.cxx index 7bc4740..e3b5f8b 100644 --- a/bpkg/archive.cxx +++ b/bpkg/archive.cxx @@ -110,7 +110,7 @@ namespace bpkg // Fall through. } - catch (const ifdstream::failure&) + catch (const io_error&) { // Child exit status doesn't matter. Just wait for the process // completion and fall through. diff --git a/bpkg/auth.cxx b/bpkg/auth.cxx index 6ef9751..75cdb45 100644 --- a/bpkg/auth.cxx +++ b/bpkg/auth.cxx @@ -4,7 +4,6 @@ #include -#include #include #include // numeric_limits #include // strlen(), strcmp() @@ -131,7 +130,7 @@ namespace bpkg const size_t n (19); if (!(s.size () > n && s.compare (0, n, "SHA256 Fingerprint=") == 0)) - throw ifdstream::failure (""); + throw io_error (""); string fp; @@ -141,7 +140,7 @@ namespace bpkg } catch (const invalid_argument&) { - throw ifdstream::failure (""); + throw io_error (""); } if (pr.wait ()) @@ -150,7 +149,7 @@ namespace bpkg // Fall through. // } - catch (const ios_base::failure&) + catch (const io_error&) { // Child exit status doesn't matter. Just wait for the process // completion and fall through. @@ -407,7 +406,7 @@ namespace bpkg // Fall through. // } - catch (const ios_base::failure&) + catch (const io_error&) { // Child exit status doesn't matter. Just wait for the process // completion and fall through. @@ -555,7 +554,7 @@ namespace bpkg ofs << *pem; ofs.close (); } - catch (const ofdstream::failure& e) + catch (const io_error& e) { fail << "unable to write certificate to " << f << ": " << e.what (); } @@ -641,7 +640,7 @@ namespace bpkg ofs << *cert_pem; ofs.close (); } - catch (const ofdstream::failure& e) + catch (const io_error& e) { fail << "unable to save certificate to temporary file " << f << ": " << e.what (); @@ -713,7 +712,7 @@ namespace bpkg // Fall through. // } - catch (const ios_base::failure&) + catch (const io_error&) { // Child exit status doesn't matter. Just wait for the process // completion and fall through. @@ -794,7 +793,7 @@ namespace bpkg // Fall through. // } - catch (const iostream::failure&) + catch (const io_error&) { // Child exit status doesn't matter. Just wait for the process // completion and fall through. diff --git a/bpkg/cfg-create.cxx b/bpkg/cfg-create.cxx index 1d8171f..2c8bd0a 100644 --- a/bpkg/cfg-create.cxx +++ b/bpkg/cfg-create.cxx @@ -104,7 +104,7 @@ namespace bpkg ofs.close (); } - catch (const ofdstream::failure& e) + catch (const io_error& e) { fail << "unable to write to " << f << ": " << e.what (); } @@ -135,7 +135,7 @@ namespace bpkg ofs.close (); } - catch (const ofdstream::failure& e) + catch (const io_error& e) { fail << "unable to write to " << f << ": " << e.what (); } @@ -154,7 +154,7 @@ namespace bpkg ofs.close (); } - catch (const ofdstream::failure& e) + catch (const io_error& e) { fail << "unable to write to " << f << ": " << e.what (); } diff --git a/bpkg/checksum.cxx b/bpkg/checksum.cxx index 3f52204..8940952 100644 --- a/bpkg/checksum.cxx +++ b/bpkg/checksum.cxx @@ -48,7 +48,7 @@ namespace bpkg l == "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"; } - catch (const ifdstream::failure&) + catch (const io_error&) { // Fall through. } @@ -110,7 +110,7 @@ namespace bpkg return pr.wait () && l.compare (0, 9, "sha256sum") == 0; } - catch (const ifdstream::failure&) + catch (const io_error&) { // Fall through. } @@ -172,7 +172,7 @@ namespace bpkg return pr.wait () && l.size () != 0 && l[0] >= '0' && l[0] <= '9'; } - catch (const ifdstream::failure&) + catch (const io_error&) { // Fall through. } @@ -359,7 +359,7 @@ namespace bpkg // Ignore these exceptions if the child process exited with an error status // since that's the source of the failure. // - catch (const iostream::failure&) + catch (const io_error&) { if (pr.wait ()) fail << "unable to read/write '" << sha256_path << "' output/input"; @@ -411,7 +411,7 @@ namespace bpkg ifdstream ifs (f, ios::binary); return sha256 (o, ifs); } - catch (const iostream::failure& e) + catch (const io_error& e) { error << "unable read " << f << ": " << e.what (); throw failed (); diff --git a/bpkg/fetch.cxx b/bpkg/fetch.cxx index 734c261..33753fb 100644 --- a/bpkg/fetch.cxx +++ b/bpkg/fetch.cxx @@ -55,7 +55,7 @@ namespace bpkg if (!(pr.wait () && l.compare (0, 9, "GNU Wget ") == 0)) return false; } - catch (const ifdstream::failure&) + catch (const io_error&) { return false; } @@ -195,7 +195,7 @@ namespace bpkg return pr.wait () && l.compare (0, 5, "curl ") == 0; } - catch (const ifdstream::failure&) + catch (const io_error&) { // Fall through. } @@ -306,7 +306,7 @@ namespace bpkg return l.compare (0, 13, "usage: fetch ") == 0; } - catch (const ifdstream::failure&) + catch (const io_error&) { // Fall through. } @@ -608,7 +608,7 @@ namespace bpkg if (pr.wait ()) fail (e.name, e.line, e.column) << e.description; } - catch (const ifdstream::failure&) + catch (const io_error&) { if (pr.wait ()) fail << "unable to read fetched " << url; @@ -673,7 +673,7 @@ namespace bpkg { error (e.name, e.line, e.column) << e.description; } - catch (const ifdstream::failure& e) + catch (const io_error& e) { error << "unable to read from " << f << ": " << e.what (); } diff --git a/bpkg/help.cxx b/bpkg/help.cxx index 3d5efb8..92253bd 100644 --- a/bpkg/help.cxx +++ b/bpkg/help.cxx @@ -50,8 +50,8 @@ namespace bpkg // return p.wait () ? 0 : 1; } - // Catch ios_base::failure as std::system_error together with the - // pager-specific exceptions. + // Catch io_error as std::system_error together with the pager-specific + // exceptions. // catch (const system_error& e) { diff --git a/bpkg/pkg-verify.cxx b/bpkg/pkg-verify.cxx index ea072d9..1423d82 100644 --- a/bpkg/pkg-verify.cxx +++ b/bpkg/pkg-verify.cxx @@ -78,7 +78,7 @@ namespace bpkg throw failed (); } } - catch (const ifdstream::failure&) + catch (const io_error&) { if (pr.wait ()) { @@ -157,7 +157,7 @@ namespace bpkg throw failed (); } - catch (const ifdstream::failure& e) + catch (const io_error& e) { if (diag) error << "unable to read from " << mf << ": " << e.what (); diff --git a/bpkg/rep-create.cxx b/bpkg/rep-create.cxx index 2d682f8..da44d3b 100644 --- a/bpkg/rep-create.cxx +++ b/bpkg/rep-create.cxx @@ -5,7 +5,6 @@ #include #include -#include #include #include // dir_iterator @@ -263,7 +262,7 @@ namespace bpkg { fail << "unable to save manifest: " << e.description; } - catch (const ofdstream::failure& e) + catch (const io_error& e) { fail << "unable to write to " << p << ": " << e.what (); } diff --git a/bpkg/rep-info.cxx b/bpkg/rep-info.cxx index cdad96b..355d8b8 100644 --- a/bpkg/rep-info.cxx +++ b/bpkg/rep-info.cxx @@ -242,7 +242,7 @@ namespace bpkg { fail << "unable to serialize manifest: " << e.description; } - catch (const ostream::failure&) + catch (const io_error&) { fail << "unable to write to STDOUT"; } diff --git a/bpkg/satisfaction.cxx b/bpkg/satisfaction.cxx index 2e2b269..23c63fd 100644 --- a/bpkg/satisfaction.cxx +++ b/bpkg/satisfaction.cxx @@ -141,7 +141,7 @@ namespace bpkg // Fall through. } - catch (const ifdstream::failure&) + catch (const io_error&) { pr.wait (); // Fall through. diff --git a/bpkg/types b/bpkg/types index 2e03675..8bff6bb 100644 --- a/bpkg/types +++ b/bpkg/types @@ -15,6 +15,7 @@ #include #include // function, reference_wrapper +#include // ios_base::failure #include // exception #include // logic_error, invalid_argument, runtime_error #include @@ -60,6 +61,7 @@ namespace bpkg using std::invalid_argument; using std::runtime_error; using std::system_error; + using io_error = std::ios_base::failure; // // -- cgit v1.1