Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TestForException_throwTest.cpp
Go to the documentation of this file.
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #include "Teuchos_Assert.hpp"
14 
15 #include "SimpleThrowFunctions.hpp"
16 
17 
18 int main(int argc, char* argv[])
19 {
20 
22 
23  Teuchos::GlobalMPISession mpiSession(&argc, &argv);
24 
25  CommandLineProcessor clp(false); // Don't throw exceptions
26 
27  bool enableStackTrace = true;
28 
29  clp.setOption("enable-stacktrace", "no-enable-stacktrace", &enableStackTrace,
30  "Determine if stacktracing is shown or not on exception throw." );
31 
32  CommandLineProcessor::EParseCommandLineReturn parse_return = clp.parse(argc,argv);
33 
34  if( parse_return != CommandLineProcessor::PARSE_SUCCESSFUL ) {
35  std::cerr << "\nEnd Result: TEST FAILED" << std::endl;
36  return parse_return;
37  }
38 
40 
41  bool success = true;
42 
43  try {
44  func_b();
45  }
46  TEUCHOS_STANDARD_CATCH_STATEMENTS(true, std::cerr, success)
47  return (success ? 0 : 1);
48 }
TEUCHOSCORE_LIB_DLL_EXPORT void TestForException_setEnableStacktrace(bool enableStrackTrace)
Set at runtime if stacktracing functionality is enabled when * exceptions are thrown.
Initialize, finalize, and query the global MPI session.
#define TEUCHOS_STANDARD_CATCH_STATEMENTS(VERBOSE, ERR_STREAM, SUCCESS_FLAG)
Simple macro that catches and reports standard exceptions and other exceptions.
int main(int argc, char *argv[])
A MPI utilities class, providing methods for initializing, finalizing, and querying the global MPI se...
Basic command line parser for input from (argc,argv[])
void func_b()
Class that helps parse command line input arguments from (argc,argv[]) and set options.