From b7f1f7bdc772127b056526996af26b8d495cc40d Mon Sep 17 00:00:00 2001 From: Daniel Larimer Date: Mon, 4 Feb 2013 11:13:02 -0500 Subject: [PATCH] adding close to rpc con, adding typedfes, fix detail error reporting --- include/fc/error_report.hpp | 3 ++- include/fc/json_rpc_connection.hpp | 2 ++ include/fc/optional.hpp | 4 +--- include/fc/string.hpp | 3 +++ include/fc/time.hpp | 3 +++ src/error_report.cpp | 5 +++++ 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/include/fc/error_report.hpp b/include/fc/error_report.hpp index dd237fe..b7725ec 100644 --- a/include/fc/error_report.hpp +++ b/include/fc/error_report.hpp @@ -48,6 +48,7 @@ namespace fc { error_frame& current(); error_report& pop_frame(); error_report& push_frame( const fc::string& file, uint64_t line, const fc::string& method, const fc::string& desc, fc::value meta = fc::value() ); + error_report& push_frame( bool detail, const fc::string& file, uint64_t line, const fc::string& method, const fc::string& desc, fc::value meta = fc::value() ); error_report& append( const error_report& e ); fc::string to_string()const; @@ -70,5 +71,5 @@ FC_REFLECT( fc::error_report, (stack) ) #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_PUSH_DETAIL( ER, ... ) (ER).push_frame( true, __FILE__, __LINE__, __func__, __VA_ARGS__ ) #define FC_REPORT_POP(ER) (ER).pop_frame() diff --git a/include/fc/json_rpc_connection.hpp b/include/fc/json_rpc_connection.hpp index c453301..7b5a9cb 100644 --- a/include/fc/json_rpc_connection.hpp +++ b/include/fc/json_rpc_connection.hpp @@ -139,6 +139,8 @@ namespace fc { namespace json { void add_method( const fc::string& name, const fc::json::rpc_server_method::ptr& func ); + virtual void close(){}; + protected: void handle_message( const value& m ); virtual void send_notice( const fc::string& m, value&& param ) = 0; diff --git a/include/fc/optional.hpp b/include/fc/optional.hpp index c0084fd..e32ff74 100644 --- a/include/fc/optional.hpp +++ b/include/fc/optional.hpp @@ -1,5 +1,4 @@ -#ifndef _FC_OPTIONAL_HPP_ -#define _FC_OPTIONAL_HPP_ +#pragma once #include namespace fc { @@ -94,4 +93,3 @@ namespace fc { } // namespace fc -#endif diff --git a/include/fc/string.hpp b/include/fc/string.hpp index 5c58de1..5f8f4cb 100644 --- a/include/fc/string.hpp +++ b/include/fc/string.hpp @@ -1,6 +1,7 @@ #pragma once #include #include +#include /** @@ -98,5 +99,7 @@ namespace fc { fc::fwd my; }; + typedef fc::optional ostring; + } // namespace fc diff --git a/include/fc/time.hpp b/include/fc/time.hpp index cdda425..57acead 100644 --- a/include/fc/time.hpp +++ b/include/fc/time.hpp @@ -2,6 +2,7 @@ #include #include #include +#include namespace fc { class microseconds { @@ -56,4 +57,6 @@ namespace fc { template void pack( Stream& s, const fc::time_point& v ); } + + typedef fc::optional otime_point; } diff --git a/src/error_report.cpp b/src/error_report.cpp index 6a4628c..a6ac843 100644 --- a/src/error_report.cpp +++ b/src/error_report.cpp @@ -68,6 +68,11 @@ fc::error_report& error_report::push_frame( const fc::string& file, uint64_t lin stack.push_back( fc::error_frame( file, line, method, desc, meta ) ); return *this; } +fc::error_report& error_report::push_frame( bool detail, const fc::string& file, uint64_t line, const fc::string& method, const fc::string& desc, fc::value meta ) +{ + stack.push_back( fc::error_frame( detail, file, line, method, desc, meta ) ); + return *this; +} fc::error_report& error_report::append( const error_report& e ) {