Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
ExceptionsTest.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // STD & STL
5 // ============================================================================
6 #include <cmath>
7 #include <cstdio>
8 #include <exception>
9 #include <iostream>
10 // ============================================================================
11 // GaudiKernel
12 // ============================================================================
15 // ============================================================================
16 // GaudiMath
17 // ============================================================================
18 #include "GaudiMath/GaudiMath.h"
19 // ============================================================================
20 // CLHEP
21 // ============================================================================
22 #include "CLHEP/GenericFunctions/Sin.hh"
23 // ============================================================================
24 // Handle CLHEP 2.0.x move to CLHEP namespace
25 namespace CLHEP {}
26 using namespace CLHEP;
27 
28 // ============================================================================
36 // ============================================================================
37 
38 int main() {
39 
40  std::cout << " Test for embedded exceptions ( 2 exception shoudl be catched) " << std::endl;
41 
42  try {
43  const GaudiMath::Function& mysin = Genfun::Sin();
44  // the exception!!! showl be thrown!
45  const GaudiMath::Function& prim = GaudiMath::Derivative( mysin, 5 );
46  std::cout << "One should never see this line!! " << std::endl;
47  mysin + prim;
48  } catch ( const std::exception& e ) {
49  std::cout << " OK 1) The exception is catched with 'what'='" << e.what() << "'" << std::endl;
50  }
51 
52  try {
53  const GaudiMath::Function& mysin = Genfun::Sin();
54  // the exception!!! showl be thrown!
55  const GaudiMath::Function& prim = GaudiMath::Derivative( mysin, 10 );
56  std::cout << "One should never see this line!! " << std::endl;
57  mysin + prim;
58  } catch ( const GaudiException& e ) { std::cout << " OK 2) " << e << std::endl; }
59 }
60 
61 // ============================================================================
62 // The END
63 // ============================================================================
Define general base for Gaudi exception.
T endl(T...args)
Genfun::AbsFunction Function
Definition: GaudiMath.h:23
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:26
T what(T...args)
STL class.
int main()