From 68e949a699a2cd81811e78b50320d61499b20a53 Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Wed, 30 Jan 2013 23:36:51 -0500 Subject: [PATCH] fix bugs --- include/fc/error_report.hpp | 8 ++++++-- src/error_report.cpp | 10 +++++++--- src/filesystem.cpp | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/include/fc/error_report.hpp b/include/fc/error_report.hpp index 57dc7ef..dd237fe 100644 --- a/include/fc/error_report.hpp +++ b/include/fc/error_report.hpp @@ -13,6 +13,7 @@ namespace fc { class error_frame { public: error_frame( const fc::string& file, uint64_t line, const fc::string& method, const fc::string& desc, fc::value m ); + error_frame( bool detail, const fc::string& file, uint64_t line, const fc::string& method, const fc::string& desc, fc::value m ); error_frame():file("unknown-file"),line(0){} error_frame(const error_frame& ); error_frame(error_frame&& ); @@ -27,8 +28,9 @@ namespace fc { fc::string file; int64_t line; fc::string method; - fc::string time; fc::optional meta; + fc::string time; + bool detail; }; typedef fc::vector error_context; @@ -40,6 +42,7 @@ namespace fc { class error_report { public: error_report(); + error_report( const fc::string& desc, fc::value meta = fc::value() ); error_report( const fc::string& file, uint64_t line, const fc::string& method, const fc::string& desc, fc::value meta = fc::value() ); error_frame& current(); @@ -60,11 +63,12 @@ namespace fc { } // namespace fc #include -FC_REFLECT( fc::error_frame, (desc)(file)(line)(method)(time)(meta) ) +FC_REFLECT( fc::error_frame, (desc)(file)(line)(method)(time)(meta)(detail) ) FC_REFLECT( fc::error_report, (stack) ) #define FC_REPORT( X, ... ) fc::error_report X( __FILE__, __LINE__, __func__, __VA_ARGS__ ) #define FC_THROW_REPORT( ... ) FC_THROW( fc::error_report( __FILE__, __LINE__, __func__, __VA_ARGS__ )) #define FC_REPORT_CURRENT(ER, ... ) (ER).pop_frame().push_frame( __FILE__, __LINE__, __func__, __VA_ARGS__ ) #define FC_REPORT_PUSH( ER, ... ) (ER).push_frame( __FILE__, __LINE__, __func__, __VA_ARGS__ ); +#define FC_REPORT_PUSH_DETAIL( ER, ... ) (ER).push_frame( true, __FILE__, __LINE__, __func__, __VA_ARGS__ ); #define FC_REPORT_POP(ER) (ER).pop_frame() diff --git a/src/error_report.cpp b/src/error_report.cpp index 4d1f2d7..6a4628c 100644 --- a/src/error_report.cpp +++ b/src/error_report.cpp @@ -8,21 +8,24 @@ namespace fc { error_frame::error_frame( const fc::string& f, uint64_t l, const fc::string& m, const fc::string& d, fc::value met ) -:desc(d),file(fc::path(f).filename().generic_string()),line(l),method(m),meta(fc::move(met)),time(fc::time_point::now()){} +:desc(d),file(fc::path(f).filename().generic_string()),line(l),method(m),meta(fc::move(met)),time(fc::time_point::now()),detail(false){} +error_frame::error_frame( bool is_detail, const fc::string& f, uint64_t l, const fc::string& m, const fc::string& d, fc::value met ) +:desc(d),file(fc::path(f).filename().generic_string()),line(l),method(m),meta(fc::move(met)),time(fc::time_point::now()),detail(is_detail){} error_report::error_report() { } error_frame::error_frame(const fc::error_frame& e) -:desc(e.desc),file(e.file),line(e.line),method(e.method),time(e.time),meta(e.meta){} +:desc(e.desc),file(e.file),line(e.line),method(e.method),meta(e.meta),time(e.time),detail(e.detail){} error_frame::error_frame(fc::error_frame&& e) :desc(fc::move(e.desc)), file(fc::move(e.file)), line(e.line), method(fc::move(e.method)), + meta(fc::move(e.meta)), time(e.time), - meta(fc::move(e.meta)) + detail(e.detail) {} fc::error_frame& fc::error_frame::operator=(const fc::error_frame& f ) { @@ -38,6 +41,7 @@ fc::error_frame& fc::error_frame::operator=(fc::error_frame&& e ) method=fc::move(e.method); time=e.time; meta=fc::move(e.meta); + detail = e.detail; return *this; } diff --git a/src/filesystem.cpp b/src/filesystem.cpp index 48fa7b5..1fe732b 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -158,7 +158,7 @@ namespace fc { } bool remove( const path& f ) { try { - boost::filesystem::remove( f ); + return boost::filesystem::remove( f ); } catch ( ... ) { FC_THROW_REPORT( "Unable to remove '${path}'", fc::value().set( "path", f ).set("exception", fc::except_str() ) ); }