Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/common/UtilExceptions.cpp
193905 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file UtilExceptions.cpp
15
/// @author Daniel Krajzewicz
16
/// @author Christian Roessel
17
/// @author Michael Behrisch
18
/// @author Felix Brack
19
/// @date Mon, 17 Dec 2001
20
///
21
// Exceptions for used by some utility classes
22
/****************************************************************************/
23
#include <config.h>
24
25
// stacktrace is not supported in MAC
26
#if defined(HAVE_BOOST) && !defined(__APPLE__)
27
#ifdef _MSC_VER
28
// needed to avoid problem in boost win winsocket
29
#pragma warning(push, 0)
30
#define WIN32_LEAN_AND_MEAN
31
#define NOMINMAX
32
#include <windows.h>
33
#include <boost/stacktrace.hpp>
34
#pragma warning(pop)
35
#else
36
#pragma GCC diagnostic push
37
#pragma GCC diagnostic ignored "-Wall"
38
#pragma GCC diagnostic ignored "-Wextra"
39
#include <boost/stacktrace.hpp>
40
#pragma GCC diagnostic pop
41
#endif
42
#endif
43
44
#include "UtilExceptions.h"
45
46
// ===========================================================================
47
// class definitions
48
// ===========================================================================
49
50
// ---------------------------------------------------------------------------
51
// ProcessError - methods
52
// ---------------------------------------------------------------------------
53
54
ProcessError::ProcessError() :
55
std::runtime_error(TL("Process Error")) {
56
// process trace
57
processTrace();
58
}
59
60
61
ProcessError::ProcessError(const std::string& msg) :
62
std::runtime_error(msg) {
63
// process trace
64
processTrace();
65
}
66
67
68
const std::string&
69
ProcessError::getTrace() const {
70
return myTrace;
71
}
72
73
74
void
75
ProcessError::processTrace() {
76
// only process if we have boost and we're not in apple
77
#if defined(HAVE_BOOST) && !defined(__APPLE__)
78
// declare stacktrace
79
boost::stacktrace::stacktrace st;
80
// convert trace using ostringstream
81
std::ostringstream oss;
82
oss << st;
83
myTrace = oss.str();
84
#endif
85
}
86
87
// ---------------------------------------------------------------------------
88
// ProcessError - methods
89
// ---------------------------------------------------------------------------
90
91
InvalidArgument::InvalidArgument(const std::string& message) :
92
ProcessError(message) {
93
}
94
95
// ---------------------------------------------------------------------------
96
// ProcessError - methods
97
// ---------------------------------------------------------------------------
98
99
EmptyData::EmptyData() :
100
ProcessError(TL("Empty Data")) {
101
}
102
103
// ---------------------------------------------------------------------------
104
// ProcessError - methods
105
// ---------------------------------------------------------------------------
106
107
FormatException::FormatException(const std::string& msg) :
108
ProcessError(msg) {
109
}
110
111
// ---------------------------------------------------------------------------
112
// ProcessError - methods
113
// ---------------------------------------------------------------------------
114
115
NumberFormatException::NumberFormatException(const std::string& data) :
116
FormatException(TLF("Invalid Number Format %", data)) {
117
}
118
119
// ---------------------------------------------------------------------------
120
// ProcessError - methods
121
// ---------------------------------------------------------------------------
122
123
TimeFormatException::TimeFormatException(const std::string& data) :
124
FormatException(TLF("Invalid Time Format %", data)) {
125
}
126
127
// ---------------------------------------------------------------------------
128
// ProcessError - methods
129
// ---------------------------------------------------------------------------
130
131
BoolFormatException::BoolFormatException(const std::string& data) :
132
FormatException(TLF("Invalid Bool Format %", data)) {
133
}
134
135
// ---------------------------------------------------------------------------
136
// ProcessError - methods
137
// ---------------------------------------------------------------------------
138
139
OutOfBoundsException::OutOfBoundsException(const std::string& msg) :
140
ProcessError(msg) {
141
}
142
143
144
// ---------------------------------------------------------------------------
145
// ProcessError - methods
146
// ---------------------------------------------------------------------------
147
148
UnknownElement::UnknownElement() :
149
ProcessError(TL("Unknown Element")) {
150
}
151
152
153
UnknownElement::UnknownElement(const std::string& msg) :
154
ProcessError(msg) {
155
}
156
157
// ---------------------------------------------------------------------------
158
// ProcessError - methods
159
// ---------------------------------------------------------------------------
160
161
IOError::IOError(const std::string& message) :
162
ProcessError(message) {
163
}
164
165