Cantera
Install
User Guide
Examples
Reference
Develop
Community
4.0.0a2
Toggle main menu visibility
Loading...
Searching...
No Matches
clib_utils.h
Go to the documentation of this file.
1
/**
2
* @file clib_utils.h
3
*/
4
5
// This file is part of Cantera. See License.txt in the top-level directory or
6
// at https://cantera.org/license.txt for license and copyright information.
7
8
#ifndef CLIB_UTILS_H
9
#define CLIB_UTILS_H
10
11
#include "
cantera/base/ctexceptions.h
"
12
#include "
cantera_clib/clib_defs.h
"
13
14
#include "
application.h
"
15
#include "
Cabinet.h
"
16
#include <iostream>
17
18
19
namespace
Cantera
20
{
21
22
//! Exception handler used at language interface boundaries.
23
/*!
24
* When called from a "catch (...)" block, this function will attempt to save
25
* an error message in global error stack and return a value indicating the
26
* type of exception caught.
27
*
28
* @param ctErrorCode Value to return if a CanteraError is caught
29
* @param otherErrorCode Value to return if a different exception is caught
30
*/
31
template
<
typename
T>
32
T
handleAllExceptions
(T ctErrorCode, T otherErrorCode)
33
{
34
// Rethrow the previous exception, then catch a more
35
// specific exception type if possible.
36
try
{
37
throw
;
38
}
catch
(
CanteraError
& cterr) {
39
Application::Instance
()->
addError
(cterr.
what
());
40
return
ctErrorCode;
41
}
catch
(std::exception& err) {
42
std::cerr <<
"Cantera: caught an instance of "
43
<< err.what() << std::endl;
44
Application::Instance
()->
addError
(err.what());
45
return
otherErrorCode;
46
}
catch
(...) {
47
std::cerr <<
"Cantera: caught an instance of "
48
"an unknown exception type"
<< std::endl;
49
Application::Instance
()->
addError
(
"unknown C++ exception"
);
50
return
otherErrorCode;
51
}
52
}
53
54
}
55
56
#endif
Cabinet.h
application.h
Cantera::Application::Instance
static Application * Instance()
Return a pointer to the one and only instance of class Application.
Definition
application.cpp:97
Cantera::Application::addError
void addError(const string &r, const string &msg="")
Set an error condition in the application class without throwing an exception.
Definition
application.h:168
Cantera::CanteraError
Base class for exceptions thrown by Cantera classes.
Definition
ctexceptions.h:66
Cantera::CanteraError::what
const char * what() const override
Get a description of the error.
Definition
ctexceptions.cpp:29
clib_defs.h
ctexceptions.h
Definitions for the classes that are thrown when Cantera experiences an error condition (also contain...
Cantera
Namespace for the Cantera kernel.
Definition
AnyMap.cpp:595
Cantera::handleAllExceptions
T handleAllExceptions(T ctErrorCode, T otherErrorCode)
Exception handler used at language interface boundaries.
Definition
clib_utils.h:32
interfaces
clib
src
clib_utils.h
Generated by
1.17.0