The Gaudi Framework  v30r3 (a5ef0a68)
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 {
27 }
28 using namespace CLHEP;
29 
30 // ============================================================================
38 // ============================================================================
39 
40 int main()
41 {
42 
43  std::cout << " Test for embedded exceptions ( 2 exception shoudl be catched) " << std::endl;
44 
45  try {
46  const GaudiMath::Function& mysin = Genfun::Sin();
47  // the exception!!! showl be thrown!
48  const GaudiMath::Function& prim = GaudiMath::Derivative( mysin, 5 );
49  std::cout << "One should never see this line!! " << std::endl;
50  mysin + prim;
51  } catch ( const std::exception& e ) {
52  std::cout << " OK 1) The exception is catched with 'what'='" << e.what() << "'" << std::endl;
53  }
54 
55  try {
56  const GaudiMath::Function& mysin = Genfun::Sin();
57  // the exception!!! showl be thrown!
58  const GaudiMath::Function& prim = GaudiMath::Derivative( mysin, 10 );
59  std::cout << "One should never see this line!! " << std::endl;
60  mysin + prim;
61  } catch ( const GaudiException& e ) {
62  std::cout << " OK 2) " << e << std::endl;
63  }
64 }
65 
66 // ============================================================================
67 // The END
68 // ============================================================================
Define general base for Gaudi exception.
T endl(T...args)
Genfun::AbsFunction Function
Definition: GaudiMath.h:24
Genfun::GaudiMathImplementation::NumericalDerivative Derivative
Definition: GaudiMath.h:27
T what(T...args)
STL class.
int main()