Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
UtilExceptions.cpp
Go to the documentation of this file.
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/****************************************************************************/
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#include "Translation.h"
46
47// ===========================================================================
48// class definitions
49// ===========================================================================
50
51// ---------------------------------------------------------------------------
52// ProcessError - methods
53// ---------------------------------------------------------------------------
54
56 std::runtime_error(TL("Process Error")) {
57 // process trace
59}
60
61
62ProcessError::ProcessError(const std::string& msg) :
63 std::runtime_error(msg) {
64 // process trace
66}
67
68
69const std::string&
71 return myTrace;
72}
73
74
75void
77// only process if we have boost and we're not in apple
78#if defined(HAVE_BOOST) && !defined(__APPLE__)
79 // declare stacktrace
80 boost::stacktrace::stacktrace st;
81 // convert trace using ostringstream
82 std::ostringstream oss;
83 oss << st;
84 myTrace = oss.str();
85#endif
86}
87
88// ---------------------------------------------------------------------------
89// ProcessError - methods
90// ---------------------------------------------------------------------------
91
92InvalidArgument::InvalidArgument(const std::string& message) :
93 ProcessError(message) {
94}
95
96// ---------------------------------------------------------------------------
97// ProcessError - methods
98// ---------------------------------------------------------------------------
99
101 ProcessError(TL("Empty Data")) {
102}
103
104// ---------------------------------------------------------------------------
105// ProcessError - methods
106// ---------------------------------------------------------------------------
107
108FormatException::FormatException(const std::string& msg) :
109 ProcessError(msg) {
110}
111
112// ---------------------------------------------------------------------------
113// ProcessError - methods
114// ---------------------------------------------------------------------------
115
117 FormatException(TLF("Invalid Number Format %", data)) {
118}
119
120// ---------------------------------------------------------------------------
121// ProcessError - methods
122// ---------------------------------------------------------------------------
123
125 FormatException(TLF("Invalid Time Format %", data)) {
126}
127
128// ---------------------------------------------------------------------------
129// ProcessError - methods
130// ---------------------------------------------------------------------------
131
133 FormatException(TLF("Invalid Bool Format %", data)) {
134}
135
136// ---------------------------------------------------------------------------
137// ProcessError - methods
138// ---------------------------------------------------------------------------
139
143
144
146 ProcessError(msg) {
147}
148
149
150// ---------------------------------------------------------------------------
151// ProcessError - methods
152// ---------------------------------------------------------------------------
153
155 ProcessError(TL("Unknown Element")) {
156}
157
158
159UnknownElement::UnknownElement(const std::string& msg) :
160 ProcessError(msg) {
161}
162
163// ---------------------------------------------------------------------------
164// ProcessError - methods
165// ---------------------------------------------------------------------------
166
167IOError::IOError(const std::string& message) :
168 ProcessError(message) {
169}
#define TL(string)
Definition MsgHandler.h:304
#define TLF(string,...)
Definition MsgHandler.h:306
BoolFormatException(const std::string &data)
constructor
EmptyData()
constructor
FormatException(const std::string &msg)
constructor
IOError(const std::string &message)
constructor
InvalidArgument(const std::string &message)
constructor
NumberFormatException(const std::string &data)
constructor
OutOfBoundsException()
constructor (default message: "Out Of Bounds")
ProcessError()
constructor
std::string myTrace
exception trace
void processTrace()
process trace
const std::string & getTrace() const
get trace
TimeFormatException(const std::string &data)
constructor
UnknownElement()
constructor
Definition json.hpp:4471