CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
testThrowFrom.cc File Reference
#include "CLHEP/Exceptions/ZMthrow.h"
#include "CLHEP/Exceptions/ZMexception.h"
#include "CLHEP/Exceptions/ZMexAction.h"
#include "CLHEP/Exceptions/ZMexClassInfo.h"
#include "CLHEP/Exceptions/ZMexSeverity.h"
#include <iostream>

Go to the source code of this file.

Functions

 ZMexStandardDefinition (ZMexception, ZMxTest)
 
int main ()
 

Function Documentation

◆ main()

int main ( )

Definition at line 28 of file testThrowFrom.cc.

28 {
29
30// std::cout << "starting...\n";
31
32
33// Not: ZMexception::setHandler( ZMexIgnoreAlways() ) ;
34// Instead:
35 ZMxTest::setSeverity( ZMexWARNING ); // Which should not abort
36
37 ZMexception::setLogger( ZMexValidationStyle(std::cout) ) ;
38
39// std::cout << "throwing...\n";
40
41 ZMthrow_from( ZMxTest("Artificial Exception"), 1000,
42 "directory/subdirectory/fictitious.file" );
43
44 ZMthrow_from( ZMxTest("Artificial backslash Exception"), 4000,
45 "directory/subdirectory\\fictitious.file" );
46
47 ZMthrow_from( ZMxTest("Artificial no slash Exception"), 4000,
48 "fictitious.file" );
49
50 ZMthrow( ZMxTest("Normal exception") );
51
52 ZMxTest::setName("MyExName");
53 ZMthrow( ZMxTest("Exception with new name") );
54
55 ZMxTest::setFacility("newFacility");
56 ZMthrow( ZMxTest("Exception from new facility") );
57
58 // -------------
59 // Done, go home
60 // -------------
61
62 ZMexception::setLogger( ZMexLogAlways(std::cout) ) ;
63
64 ZMxTest::setSeverity( ZMexERROR ); // Which should not abort
65#ifndef DEFECT_NO_EXCEPTIONS
66 try {
67#endif
68 ZMthrow( ZMxTest("Ordinary Error") );
69#ifndef DEFECT_NO_EXCEPTIONS
70 }
71 catch( ZMexception & e ) {
72 std::cerr << "Caught: " << e.name() << "\n";
73 }
74#endif
75
76 return 0;
77
78} // main()
#define ZMthrow(userExcept)
Definition: ZMthrow.h:97
#define ZMthrow_from(userExcept, line, file)
Definition: ZMthrow.h:75
virtual std::string name() const
Definition: ZMexception.cc:106
@ ZMexWARNING
Definition: ZMexSeverity.h:41
@ ZMexERROR
Definition: ZMexSeverity.h:46

◆ ZMexStandardDefinition()

ZMexStandardDefinition ( ZMexception  ,
ZMxTest   
)