error object
This commit is contained in:
parent
1cb036ae63
commit
9225ab4726
3 changed files with 60 additions and 0 deletions
16
include/fc/json_rpc_error_object.hpp
Normal file
16
include/fc/json_rpc_error_object.hpp
Normal 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) )
|
||||||
38
include/fc/json_rpc_ssh_process_client.hpp
Normal file
38
include/fc/json_rpc_ssh_process_client.hpp
Normal 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;
|
||||||
|
|
||||||
|
};
|
||||||
|
} }
|
||||||
6
src/json_rpc_error_object.cpp
Normal file
6
src/json_rpc_error_object.cpp
Normal 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)){}
|
||||||
|
}}
|
||||||
Loading…
Reference in a new issue