#include <iostream>
#include <stdexcept>
class sample_event_exception_logger_t final
{
public:
const std::exception & event_exception,
{
std::cerr
<< "Event_exception, coop:"
<< coop << "; "
" error: "
<< event_exception.what()
<< std::endl;
}
};
{
public:
a_hello_t( context_t ctx ) :
so_5::agent_t( ctx )
{}
{
std::make_unique<sample_event_exception_logger_t>() );
throw std::runtime_error( "sample exception" );
}
{
}
};
int main()
{
try
{
{
} );
}
catch( const std::exception & ex )
{
std::cerr << "Error: " << ex.what() << std::endl;
return 1;
}
return 0;
}
A helper header file for including all public SObjectizer stuff.
virtual exception_reaction_t so_exception_reaction() const noexcept
A reaction from SObjectizer to an exception from agent's event.
environment_t & so_environment() const noexcept
Access to the SObjectizer Environment which this agent is belong.
virtual void so_evt_start()
Hook on agent start inside SObjectizer.
Type of smart handle for a cooperation.
coop_handle_t register_agent_as_coop(std::unique_ptr< A > agent)
Register single agent as a cooperation.
void install_exception_logger(event_exception_logger_unique_ptr_t logger)
Set up an exception logger.
std::unique_ptr< Agent > make_agent(Args &&... args)
Helper method for simplification of agents creation.
An interface for the exception logging.
virtual void log_exception(const std::exception &event_exception, const coop_handle_t &coop) noexcept=0
Log the exception caught.
Private part of message limit implementation.
void launch(Init_Routine &&init_routine)
Launch a SObjectizer Environment with default parameters.
exception_reaction_t
A reaction of SObjectizer to an exception from agent event.
@ deregister_coop_on_exception