This commit is contained in:
Daniel Larimer 2013-01-30 23:36:51 -05:00
parent f19821dae1
commit 68e949a699
3 changed files with 14 additions and 6 deletions

View file

@ -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<fc::value> meta;
fc::string time;
bool detail;
};
typedef fc::vector<error_frame> 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.hpp>
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()

View file

@ -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;
}

View file

@ -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() ) );
}