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-2022 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 <config.h>
25 #include <string>
26 #include <stdexcept>
27 
28 
29 // ===========================================================================
30 // class definitions
31 // ===========================================================================
37 class ProcessError : public std::runtime_error {
38 public:
41  : std::runtime_error("Process Error") {}
42 
44  ProcessError(const std::string& msg)
45  : std::runtime_error(msg) {}
46 };
47 
48 
54 class InvalidArgument : public ProcessError {
55 public:
57  InvalidArgument(const std::string& message)
58  : ProcessError(message) {}
59 };
60 
61 
66 class EmptyData : public ProcessError {
67 public:
70  : ProcessError("Empty Data") {}
71 };
72 
73 
79 class FormatException : public ProcessError {
80 public:
82  FormatException(const std::string& msg)
83  : ProcessError(msg) {}
84 };
85 
86 
94 public:
96  NumberFormatException(const std::string& data)
97  : FormatException("Invalid Number Format '" + data + "'") {}
98 };
99 
100 
107 public:
109  TimeFormatException(const std::string& data)
110  : FormatException("Invalid Time Format '" + data + "'") {}
111 };
112 
113 
120 public:
122  BoolFormatException(const std::string& data)
123  : FormatException("Invalid Bool Format '" + data + "'") {}
124 };
125 
126 
133 public:
136  : ProcessError("Out Of Bounds") {}
137 };
138 
139 
145 class UnknownElement : public ProcessError {
146 public:
149  : ProcessError("Unknown Element") {}
150 
152  UnknownElement(const std::string& msg)
153  : ProcessError(msg) {}
154 };
155 
159 class IOError : public ProcessError {
160 public:
162  IOError(const std::string& message)
163  : ProcessError(message) {}
164 };
165 
167 #ifdef MSVC_TEST_SERVER
168 #ifdef _DEBUG
169 #define SOFT_ASSERT(expr) if (!(expr)) {throw ProcessError("should not happen");}
170 #else
171 #define SOFT_ASSERT(expr)
172 #endif
173 #else
174 #define SOFT_ASSERT(expr) assert(expr);
175 #endif
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