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-2025 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
46// ===========================================================================
47// class definitions
48// ===========================================================================
49
50// ---------------------------------------------------------------------------
51// ProcessError - methods
52// ---------------------------------------------------------------------------
53
55 std::runtime_error(TL("Process Error")) {
56 // process trace
58}
59
60
61ProcessError::ProcessError(const std::string& msg) :
62 std::runtime_error(msg) {
63 // process trace
65}
66
67
68const std::string&
70 return myTrace;
71}
72
73
74void
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
91InvalidArgument::InvalidArgument(const std::string& message) :
92 ProcessError(message) {
93}
94
95// ---------------------------------------------------------------------------
96// ProcessError - methods
97// ---------------------------------------------------------------------------
98
100 ProcessError(TL("Empty Data")) {
101}
102
103// ---------------------------------------------------------------------------
104// ProcessError - methods
105// ---------------------------------------------------------------------------
106
107FormatException::FormatException(const std::string& msg) :
108 ProcessError(msg) {
109}
110
111// ---------------------------------------------------------------------------
112// ProcessError - methods
113// ---------------------------------------------------------------------------
114
116 FormatException(TLF("Invalid Number Format %", data)) {
117}
118
119// ---------------------------------------------------------------------------
120// ProcessError - methods
121// ---------------------------------------------------------------------------
122
124 FormatException(TLF("Invalid Time Format %", data)) {
125}
126
127// ---------------------------------------------------------------------------
128// ProcessError - methods
129// ---------------------------------------------------------------------------
130
132 FormatException(TLF("Invalid Bool Format %", data)) {
133}
134
135// ---------------------------------------------------------------------------
136// ProcessError - methods
137// ---------------------------------------------------------------------------
138
140 ProcessError(msg) {
141}
142
143
144// ---------------------------------------------------------------------------
145// ProcessError - methods
146// ---------------------------------------------------------------------------
147
149 ProcessError(TL("Unknown Element")) {
150}
151
152
153UnknownElement::UnknownElement(const std::string& msg) :
154 ProcessError(msg) {
155}
156
157// ---------------------------------------------------------------------------
158// ProcessError - methods
159// ---------------------------------------------------------------------------
160
161IOError::IOError(const std::string& message) :
162 ProcessError(message) {
163}
#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(const std::string &msg=TL("Out Of Bounds"))
constructor
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