Eclipse SUMO - Simulation of Urban MObility
UtilExceptions.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2020 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 #pragma once
24 #include <string>
25 #include <stdexcept>
26 
27 
28 // ===========================================================================
29 // class definitions
30 // ===========================================================================
36 class ProcessError : public std::runtime_error {
37 public:
40  : std::runtime_error("Process Error") {}
41 
43  ProcessError(const std::string& msg)
44  : std::runtime_error(msg) {}
45 };
46 
47 
53 class InvalidArgument : public ProcessError {
54 public:
56  InvalidArgument(const std::string& message)
57  : ProcessError(message) {}
58 };
59 
60 
65 class EmptyData : public ProcessError {
66 public:
69  : ProcessError("Empty Data") {}
70 };
71 
72 
78 class FormatException : public ProcessError {
79 public:
81  FormatException(const std::string& msg)
82  : ProcessError(msg) {}
83 };
84 
85 
93 public:
95  NumberFormatException(const std::string& data)
96  : FormatException("Invalid Number Format '" + data + "'") {}
97 };
98 
99 
106 public:
108  TimeFormatException(const std::string& data)
109  : FormatException("Invalid Time Format '" + data + "'") {}
110 };
111 
112 
119 public:
121  BoolFormatException(const std::string& data)
122  : FormatException("Invalid Bool Format '" + data + "'") {}
123 };
124 
125 
132 public:
135  : ProcessError("Out Of Bounds") {}
136 };
137 
138 
144 class UnknownElement : public ProcessError {
145 public:
148  : ProcessError("Unknown Element") {}
149 
151  UnknownElement(const std::string& msg)
152  : ProcessError(msg) {}
153 };
154 
158 class IOError : public ProcessError {
159 public:
161  IOError(const std::string& message)
162  : ProcessError(message) {}
163 };
164 
168 class AbortParsing : public ProcessError {
169 public:
171  AbortParsing(const std::string& message)
172  : ProcessError(message) {}
173 };
174 
176 #ifdef MSVC_TEST_SERVER
177 #ifdef _DEBUG
178 #define SOFT_ASSERT(expr) if (!(expr)) {throw ProcessError("should not happen");}
179 #else
180 #define SOFT_ASSERT(expr)
181 #endif
182 #else
183 #define SOFT_ASSERT(expr) assert(expr);
184 #endif
AbortParsing(const std::string &message)
constructor
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
ProcessError()
constructor
ProcessError(const std::string &msg)
constructor
TimeFormatException(const std::string &data)
constructor
UnknownElement(const std::string &msg)
constructor
UnknownElement()
constructor