SIMLIB/C++
3.09
Toggle main menu visibility
Loading...
Searching...
No Matches
src
error.cc
Go to the documentation of this file.
1
/////////////////////////////////////////////////////////////////////////////
2
//! \file error.cc error messages processing
3
//
4
// Copyright (c) 1991-2004 Petr Peringer
5
//
6
// This library is licensed under GNU Library GPL. See the file COPYING.
7
//
8
9
// internal error messages
10
11
////////////////////////////////////////////////////////////////////////////
12
// interface
13
//
14
15
#include "
simlib.h
"
16
#include "
internal.h
"
17
18
#include <cstdlib>
19
#include <cstdio>
20
#include <cstdarg>
21
22
23
////////////////////////////////////////////////////////////////////////////
24
// implementation
25
//
26
27
namespace
simlib3
{
28
29
SIMLIB_IMPLEMENTATION
;
30
31
#define _ERR_TXT "\nERROR, Time=%g : %s \n"
32
#define _INT_ERR_TXT "\nERROR, Time=%g : %s (file:%s line:%d)\n"
33
#define _ABORT_TXT "\n ========== Simulation aborted ========== \n"
34
#define _WARNING_TXT "\nWARNING, Time=%g : %s \n"
35
36
////////////////////////////////////////////////////////////////////////////
37
/// print error message and abort program
38
void
SIMLIB_error
(
const
enum
_ErrEnum
N)
39
{
40
_Print
(
_ERR_TXT
, (
double
)
Time
,
_ErrMsg
(N));
41
_Print
(
_ABORT_TXT
);
42
SIMLIB_Phase
=
ERROREXIT
;
43
SIMLIB_DynamicFlag
=
false
;
44
exit(3);
45
}
46
47
/// print error message and abort program
48
void
SIMLIB_error
(
const
char
*fmt, ... )
49
{
50
char
s[100];
51
va_list argptr;
52
va_start(argptr, fmt);
53
vsnprintf(s,
sizeof
(s), fmt, argptr);
54
va_end(argptr);
55
_Print
(
_ERR_TXT
, (
double
)
Time
, s);
56
_Print
(
_ABORT_TXT
);
57
exit(1);
58
}
59
60
/// print error message and abort program
61
void
SIMLIB_error
(
const
char
*filename,
const
int
linenum)
62
{
63
_Print
(
_INT_ERR_TXT
, (
double
)
Time
,
64
_ErrMsg
(
InternalError
),
65
filename, linenum);
66
_Print
(
_ABORT_TXT
);
67
SIMLIB_Phase
=
ERROREXIT
;
68
SIMLIB_DynamicFlag
=
false
;
// if in continuous simulation algorithm
69
exit(3);
70
}
71
72
////////////////////////////////////////////////////////////////////////////
73
/// print warning message and continue
74
void
SIMLIB_warning
(
const
enum
_ErrEnum
N )
75
{
76
_Print
(
_WARNING_TXT
, (
double
)
Time
,
_ErrMsg
(N));
77
}
78
79
/// print warning message and continue
80
void
SIMLIB_warning
(
const
char
*fmt, ... )
81
{
82
char
s[100];
83
va_list argptr;
84
va_start(argptr, fmt);
85
vsnprintf(s,
sizeof
(s), fmt, argptr);
86
_Print
(
_ERR_TXT
, (
double
)
Time
, s);
87
va_end(argptr);
88
}
89
90
}
// namespace
91
_WARNING_TXT
#define _WARNING_TXT
Definition
error.cc:34
_ABORT_TXT
#define _ABORT_TXT
Definition
error.cc:33
_INT_ERR_TXT
#define _INT_ERR_TXT
Definition
error.cc:32
_ERR_TXT
#define _ERR_TXT
Definition
error.cc:31
internal.h
Internal header file for SIMLIB/C++.
simlib3
Implementation of class CalendarList interface is static - using global functions in SQS namespace.
Definition
algloop.cc:32
simlib3::Time
const double & Time
model time (is NOT the block)
Definition
run.cc:48
simlib3::SIMLIB_DynamicFlag
bool SIMLIB_DynamicFlag
in dynamic section
Definition
intg.cc:56
simlib3::SIMLIB_error
void SIMLIB_error(const enum _ErrEnum N)
print error message and abort program
Definition
error.cc:38
simlib3::ERROREXIT
@ ERROREXIT
Definition
internal.h:81
simlib3::SIMLIB_IMPLEMENTATION
SIMLIB_IMPLEMENTATION
Definition
algloop.cc:34
simlib3::_Print
int _Print(const char *fmt,...)
Definition
print.cc:68
simlib3::SIMLIB_warning
void SIMLIB_warning(const enum _ErrEnum N)
print warning message and continue
Definition
error.cc:74
simlib3::_ErrEnum
_ErrEnum
Definition
errors.cc:10
simlib3::InternalError
@ InternalError
Definition
errors.cc:13
simlib3::SIMLIB_Phase
SIMLIB_Phase_t SIMLIB_Phase
Definition
run.cc:57
simlib3::_ErrMsg
const char * _ErrMsg(enum _ErrEnum N)
Definition
errors.cc:97
simlib.h
Main SIMLIB/C++ interface.
Generated on
for SIMLIB/C++ by
1.18.0