Resilient
Public Member Functions | List of all members
resilient::Throws< T > Class Template Reference

A detector which detect whether a function throws an exception of a given type. More...

#include <throws.hpp>

Inheritance diagram for resilient::Throws< T >:
[legend]

Public Member Functions

template<typename Q >
returned_failure_t< typename FailureDetectorTag< ExceptionThrown< T > >::failure_typesdetect (ICallResult< Q > &result)
 Check whether the result contains an exception of the expected type. More...
 
- Public Member Functions inherited from resilient::StatelessDetector< Throws< T > >
NoState preRun ()
 Does nothing. More...
 
decltype(auto) postRun (NoState, ICallResult< T > &result)
 Detect failures by invoking the Detector. More...
 
decltype(auto) postRun (NoState, ICallResult< T > &result) const
 

Additional Inherited Members

- Public Types inherited from resilient::FailureDetectorTag< ExceptionThrown< T > >
using failure_types = std::tuple< FailureTypes... >
 Tuple composed of the possible failure types the detector can detect. More...
 

Detailed Description

template<typename T>
class resilient::Throws< T >

A detector which detect whether a function throws an exception of a given type.

If the detected function throws an exception of the expected type then this class returns ExceptionThrown.

Note
This detector also matches exceptions derived from the expected type. If an exception type B derives from A, Throws<A> returns a failure if an instance of B is thrown.
Warning
When using several Throws in an Any detector be sure to put instance especting the most specific exception first and the least specific exception last, otherwise the latter will always detect the exception and the most specific one will never be called.
Template Parameters
TThe type of the exception.

Member Function Documentation

template<typename T >
template<typename Q >
returned_failure_t<typename FailureDetectorTag<ExceptionThrown<T> >::failure_types> resilient::Throws< T >::detect ( ICallResult< Q > &  result)
inline

Check whether the result contains an exception of the expected type.

Template Parameters
QThe return type of the detected function
Parameters
resultThe result of invoking the detected function.
Returns
ExceptionThrown if an exception occurred and the type is the expected one, NoFailure otherwise.

The documentation for this class was generated from the following file: