-
Notifications
You must be signed in to change notification settings - Fork 298
/
ModelicaSimulationError.h
70 lines (63 loc) · 2.94 KB
/
ModelicaSimulationError.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#pragma once
/** @addtogroup coreUtils
*
* @{
*/
//Enum for error types that can occur
enum SIMULATION_ERROR {
SOLVER, //all errors occur in solver (Euler,CVode)
ALGLOOP_SOLVER, //all errors occur in non-,lin-solver (Nox,Kinsol,Newton,Hybrj)
MODEL_EQ_SYSTEM, //all errors occur in model system class during simulation
ALGLOOP_EQ_SYSTEM,//all errors occur in algloop system class during simulation
MODEL_FACTORY, //all errors occur model system factory classes
SIMMANAGER,//all errors occur in simulation manager
EVENT_HANDLING,//all errors occur during event handling
TIME_EVENTS, //all errors occur during handling time events
DATASTORAGE , //all errors occur during write data (TextfileWriter,MatfileWriter,BufferReaderWriter
UTILITY,//all errors occur in utility functions
MODEL_ARRAY_FUNCTION,//all errors occur in array functions
MATH_FUNCTION //all errors occur in math functions
};
/*
Exception class for all simulation errors
*/
class ModelicaSimulationError : public runtime_error
{
public:
/**
* Create a new modelica error object with the given arguments.
* @param error_id The identifier related to the sender of the error. \see SIMULATION_ERROR for detail.
* @param error_info Error message that should be shown.
* @param description More detailed description of the occurred error e.g. the error-message of the inner exception
* @param suppress Set to true if the error should not appear on std::err and std::out.
*/
ModelicaSimulationError(SIMULATION_ERROR error_id, const string& error_info, string description = "", bool suppress = false)
: runtime_error(error_info + (description.size() > 0 ? "\n" + description : ""))
, _error_id(error_id)
, _suppress(suppress)
{
}
SIMULATION_ERROR getErrorID()
{
return _error_id;
}
bool isSuppressed()
{
return _suppress;
}
private:
SIMULATION_ERROR _error_id;
bool _suppress;
};
//Helper functions to convert the error id to a readable format
#if defined (__vxworks) || defined (__TRICORE__)
/* adrpo: undefine BOOST_EXTENSION_EXPORT_DECL for these targets */
#define BOOST_EXTENSION_EXPORT_DECL
#endif
//Helper functions to convert the error id to a readable format
BOOST_EXTENSION_EXPORT_DECL string error_id_string(SIMULATION_ERROR id);
//Helper functions to extend an error information for new additional string and time stamp
BOOST_EXTENSION_EXPORT_DECL string add_error_info(string new_info,string info,SIMULATION_ERROR id,double& time);
//Helper functions to extend an error information for new additional string
BOOST_EXTENSION_EXPORT_DECL string add_error_info(string new_info,string info,SIMULATION_ERROR id);
/** @} */ // end of coreUtils