augment the PEP_STATUS with the error stack

JSON-27
Roker 6 years ago
parent 76996b6528
commit 15cefec20e

@ -2,6 +2,7 @@
#define JSON_ADAPTER_CONTEXT_HH
#include <string>
#include "json_spirit/json_spirit_value.h"
class Context
{
@ -9,6 +10,7 @@ public:
virtual ~Context() = default;
virtual bool verify_security_token(const std::string& token) const = 0;
virtual void augment(json_spirit::Value& value) = 0;
};
#endif // JSON_ADAPTER_CONTEXT_HH

@ -388,6 +388,9 @@ public:
out_params.reserve( 1 + Helper::nr_of_output_params );
js::Value ret = Helper::call(fn, context, out_params, *p_params);
context->augment(ret); // used e.g. add some debug infos to the status return value
out_params.push_back( ret );
return out_params;
}

@ -449,7 +449,7 @@ std::string getSessions()
template<>
PEP_SESSION from_json(const js::Value& v)
PEP_SESSION from_json(const js::Value& /* not used */)
{
const auto id = std::this_thread::get_id();
const auto q = session_registry.find( id );
@ -866,6 +866,15 @@ bool JsonAdapter::verify_security_token(const std::string& s) const
}
void JsonAdapter::augment(json_spirit::Value& value)
{
js::Object o = value.get_obj();
PEP_SESSION session = from_json<PEP_SESSION>(value);
auto errorstack = get_errorstack(session);
o.emplace_back( "errorstack", to_json(errorstack) );
}
void JsonAdapter::registerEventListener(const std::string& address, unsigned port, const std::string& securityContext)
{
const auto key = std::make_pair(address, port);

@ -45,6 +45,8 @@ public:
// returns 'true' if 's' is the security token created by the function above.
virtual bool verify_security_token(const std::string& s) const override;
virtual void augment(json_spirit::Value& value) override;
static
unsigned apiVersion();
@ -65,6 +67,7 @@ public:
// returns the associated log stream (either std::cerr or nulllogger)
std::ostream& Log() const;
private:
struct Internal;

Loading…
Cancel
Save