Stan  1.0
probability, sampling & optimization
boost_error_handling.hpp
Go to the documentation of this file.
1 #ifndef __STAN__MATH__BOOST_ERROR_HANDLING_HPP__
2 #define __STAN__MATH__BOOST_ERROR_HANDLING_HPP__
3 
4 #include <boost/math/policies/policy.hpp>
5 #include <boost/math/policies/error_handling.hpp>
6 #include <boost/math/distributions/detail/common_error_handling.hpp>
7 
8 namespace stan {
9  namespace math {
10  namespace policies {
11  namespace detail {
12  using boost::math::policies::detail::raise_error;
13  template <class T_result, class T_val>
14  inline T_result raise_domain_error(const char* function,
15  const char* message,
16  const T_val& val,
17  const ::boost::math::policies::domain_error< ::boost::math::policies::throw_on_error>&) {
18  raise_error<std::domain_error, T_val>(function, message, val);
19  // we never get here:
20  return std::numeric_limits<T_result>::quiet_NaN();
21  }
22 
23  template <class T_result, class T_val>
24  inline T_result raise_domain_error(const char* ,
25  const char* ,
26  const T_val& ,
27  const ::boost::math::policies::domain_error< ::boost::math::policies::ignore_error>&) {
28  // This may or may not do the right thing, but the user asked for the error
29  // to be ignored so here we go anyway:
30  return std::numeric_limits<T_result>::quiet_NaN();
31  }
32 
33  template <class T_result, class T_val>
34  inline T_result raise_domain_error(const char* ,
35  const char* ,
36  const T_val& ,
37  const ::boost::math::policies::domain_error< ::boost::math::policies::errno_on_error>&) {
38  errno = EDOM;
39  // This may or may not do the right thing, but the user asked for the error
40  // to be silent so here we go anyway:
41  return std::numeric_limits<T_result>::quiet_NaN();
42  }
43 
44  template <class T_result, class T_val>
45  inline T_result raise_domain_error(const char* function,
46  const char* message,
47  const T_val& val,
48  const ::boost::math::policies::domain_error< ::boost::math::policies::user_error>&) {
49  return user_domain_error(function, message, val);
50  }
51 
52  }
53 
54  template <class T_result, class T_val, class Policy>
55  inline T_result raise_domain_error(const char* function,
56  const char* message,
57  const T_val& val,
58  const Policy&) {
59  typedef typename Policy::domain_error_type policy_type;
60  return detail::raise_domain_error<T_result,T_val>(function,
61  message ? message : "Domain Error evaluating function at %1%",
62  val,
63  policy_type());
64 
65  }
66  }
67  }
68 
69 }
70 
71 
72 #endif
T_result raise_domain_error(const char *function, const char *message, const T_val &val, const ::boost::math::policies::domain_error< ::boost::math::policies::throw_on_error > &)
T_result raise_domain_error(const char *function, const char *message, const T_val &val, const Policy &)
Probability, optimization and sampling library.
Definition: agrad.cpp:6

     [ Stan Home Page ] © 2011–2012, Stan Development Team.