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#include <windows.h>
29#include <boost/stacktrace.hpp>
30#else
31#pragma GCC diagnostic push
32#pragma GCC diagnostic ignored "-Wall"
33#pragma GCC diagnostic ignored "-Wextra"
34#include <boost/stacktrace.hpp>
35#pragma GCC diagnostic pop
36#endif
37#endif
38
39#include "UtilExceptions.h"
40#include "Translation.h"
41
42// ===========================================================================
43// class definitions
44// ===========================================================================
45
46// ---------------------------------------------------------------------------
47// ProcessError - methods
48// ---------------------------------------------------------------------------
49
51 std::runtime_error(TL("Process Error")) {
52 // process trace
54}
55
56
57ProcessError::ProcessError(const std::string& msg) :
58 std::runtime_error(msg) {
59 // process trace
61}
62
63
64const std::string&
66 return myTrace;
67}
68
69
70void
72// only process if we have boost and we're not in apple
73#if defined(HAVE_BOOST) && !defined(__APPLE__)
74 // declare stacktrace
75 boost::stacktrace::stacktrace st;
76 // convert trace using ostringstream
77 std::ostringstream oss;
78 oss << st;
79 myTrace = oss.str();
80#endif
81}
82
83// ---------------------------------------------------------------------------
84// ProcessError - methods
85// ---------------------------------------------------------------------------
86
87InvalidArgument::InvalidArgument(const std::string& message) :
88 ProcessError(message) {
89}
90
91// ---------------------------------------------------------------------------
92// ProcessError - methods
93// ---------------------------------------------------------------------------
94
96 ProcessError(TL("Empty Data")) {
97}
98
99// ---------------------------------------------------------------------------
100// ProcessError - methods
101// ---------------------------------------------------------------------------
102
103FormatException::FormatException(const std::string& msg) :
104 ProcessError(msg) {
105}
106
107// ---------------------------------------------------------------------------
108// ProcessError - methods
109// ---------------------------------------------------------------------------
110
112 FormatException(TLF("Invalid Number Format %", data)) {
113}
114
115// ---------------------------------------------------------------------------
116// ProcessError - methods
117// ---------------------------------------------------------------------------
118
120 FormatException(TLF("Invalid Time Format %", data)) {
121}
122
123// ---------------------------------------------------------------------------
124// ProcessError - methods
125// ---------------------------------------------------------------------------
126
128 FormatException(TLF("Invalid Bool Format %", data)) {
129}
130
131// ---------------------------------------------------------------------------
132// ProcessError - methods
133// ---------------------------------------------------------------------------
134
138
139
141 ProcessError(msg) {
142}
143
144
145// ---------------------------------------------------------------------------
146// ProcessError - methods
147// ---------------------------------------------------------------------------
148
150 ProcessError(TL("Unknown Element")) {
151}
152
153
154UnknownElement::UnknownElement(const std::string& msg) :
155 ProcessError(msg) {
156}
157
158// ---------------------------------------------------------------------------
159// ProcessError - methods
160// ---------------------------------------------------------------------------
161
162IOError::IOError(const std::string& message) :
163 ProcessError(message) {
164}
#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:5639