error object

This commit is contained in:
Daniel Larimer 2012-11-11 22:05:49 -05:00
parent 1cb036ae63
commit 9225ab4726
3 changed files with 60 additions and 0 deletions

View file

@ -0,0 +1,16 @@
#pragma once
namespace fc { namespace json {
struct error_object {
error_object( const fc::string& msg = fc::string(), fc::value v = fc::value(), int64_t c = -32000);
int64_t code;
fc::string message;
fc::optional<fc::value> data;
};
} }
#include <fc/reflect.hpp>
FC_REFLECT( fc::json::error_object, (code)(message)(data) )

View file

@ -0,0 +1,38 @@
#pragma once
#include <fc/json_rpc_client.hpp>
#include <fc/ssh/process.hpp>
namespace fc { namespace json {
template<typename InterfaceType>
class rpc_ssh_process_client : public ptr<InterfaceType,fc::json::detail::rpc_member> {
public:
rpc_ssh_process_client(){}
bool valid()const { return proc.valid(); }
rpc_ssh_process_client( const fc::ssh::process& proc )
{
con.reset( new fc::json::rpc_stream_connection( proc.out_stream(), proc.in_stream() ) );
this->_vtable.reset(new fc::detail::vtable<InterfaceType,fc::json::detail::rpc_member>() );
this->_vtable->template visit<InterfaceType>( fc::json::detail::vtable_visitor(_con) );
}
rpc_ssh_process_client& operator = ( const fc::ssh::process& proc ) {
con.reset( new fc::json::rpc_stream_connection( proc.out_stream(), proc.in_stream() ) );
this->_vtable.reset(new fc::detail::vtable<InterfaceType,fc::json::detail::rpc_member>() );
this->_vtable->template visit<InterfaceType>( fc::json::detail::vtable_visitor(_con) );
return *this;
}
/**
* @brief returns a stream that reads from the process' stderr
*/
fc::istream& err_stream() { return proc.err_stream(); }
fc::ssh::process& get_ssh_process() { return proc; }
private:
fc::ssh::process proc;
fc::json::rpc_stream_connection::ptr _con;
};
} }

View file

@ -0,0 +1,6 @@
#include <fc/json_rpc_error_object.hpp>
namespace fc { namespace json {
error_object::error_object( const fc::string& msg, fc::value v, int c )
:code(c),message(m),data(fc::move(v)){}
}}