From becea47ac3066c7d8d448d0e428cd84d351061e3 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 16 Nov 2016 10:16:01 +0000 Subject: Use assertThrow where possible --- libdevcore/CommonIO.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'libdevcore/CommonIO.cpp') diff --git a/libdevcore/CommonIO.cpp b/libdevcore/CommonIO.cpp index 8dbcb00a..97505b54 100644 --- a/libdevcore/CommonIO.cpp +++ b/libdevcore/CommonIO.cpp @@ -30,11 +30,11 @@ #include #endif #include -#include "Exceptions.h" +#include "Assertions.h" + using namespace std; using namespace dev; - template inline _T contentsGeneric(std::string const& _file) { @@ -83,8 +83,7 @@ void dev::writeFile(std::string const& _file, bytesConstRef _data, bool _writeDe ofstream s(_file, ios::trunc | ios::binary); s.write(reinterpret_cast(_data.data()), _data.size()); - if (!s) - BOOST_THROW_EXCEPTION(FileError() << errinfo_comment("Could not write to file: " + _file)); + assertThrow(s, FileError, "Could not write to file: " + _file); DEV_IGNORE_EXCEPTIONS(fs::permissions(_file, fs::owner_read|fs::owner_write)); } } -- cgit v1.2.3 From a3bd670154da3c8cc153da4b2535cd3012d75885 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 21 Jun 2017 21:46:56 +0100 Subject: Remove obscure DEV_IGNORE_EXCEPTIONS macro --- libdevcore/CommonIO.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'libdevcore/CommonIO.cpp') diff --git a/libdevcore/CommonIO.cpp b/libdevcore/CommonIO.cpp index 97505b54..52829455 100644 --- a/libdevcore/CommonIO.cpp +++ b/libdevcore/CommonIO.cpp @@ -78,12 +78,24 @@ void dev::writeFile(std::string const& _file, bytesConstRef _data, bool _writeDe if (!fs::exists(p.parent_path())) { fs::create_directories(p.parent_path()); - DEV_IGNORE_EXCEPTIONS(fs::permissions(p.parent_path(), fs::owner_all)); + try + { + fs::permissions(p.parent_path(), fs::owner_all); + } + catch (...) + { + } } ofstream s(_file, ios::trunc | ios::binary); s.write(reinterpret_cast(_data.data()), _data.size()); assertThrow(s, FileError, "Could not write to file: " + _file); - DEV_IGNORE_EXCEPTIONS(fs::permissions(_file, fs::owner_read|fs::owner_write)); + try + { + fs::permissions(_file, fs::owner_read|fs::owner_write); + } + catch (...) + { + } } } -- cgit v1.2.3