fix doc example typo
[boost.git] / boost / statechart / exception_translator.hpp
bloba030468e03cbf8c3bc30954fe6ec358ca261d105
1 #ifndef BOOST_STATECHART_EXCEPTION_TRANSLATOR_HPP_INCLUDED
2 #define BOOST_STATECHART_EXCEPTION_TRANSLATOR_HPP_INCLUDED
3 //////////////////////////////////////////////////////////////////////////////
4 // Copyright 2002-2006 Andreas Huber Doenni
5 // Distributed under the Boost Software License, Version 1.0. (See accompany-
6 // ing file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 //////////////////////////////////////////////////////////////////////////////
11 #include <boost/statechart/event.hpp>
12 #include <boost/statechart/result.hpp>
16 namespace boost
18 namespace statechart
23 //////////////////////////////////////////////////////////////////////////////
24 class exception_thrown : public event< exception_thrown > {};
28 //////////////////////////////////////////////////////////////////////////////
29 template< class ExceptionEvent = exception_thrown >
30 class exception_translator
32 public:
33 //////////////////////////////////////////////////////////////////////////
34 // The following declarations should be private.
35 // They are only public because many compilers lack template friends.
36 //////////////////////////////////////////////////////////////////////////
37 template< class Action, class ExceptionEventHandler >
38 result operator()( Action action, ExceptionEventHandler eventHandler )
40 try
42 return action();
44 catch ( ... )
46 return eventHandler( ExceptionEvent() );
53 } // namespace statechart
54 } // namespace boost
58 #endif