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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
18 // Exceptions for used by some utility classes
19 /****************************************************************************/
20 #ifndef UtilExceptions_h
21 #define UtilExceptions_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 
28 #include <string>
29 #include <stdexcept>
30 
31 
32 // ===========================================================================
33 // class definitions
34 // ===========================================================================
40 class ProcessError : public std::runtime_error {
41 public:
44  : std::runtime_error("Process Error") {}
45 
47  ProcessError(const std::string& msg)
48  : std::runtime_error(msg) {}
49 };
50 
51 
57 class InvalidArgument : public ProcessError {
58 public:
60  InvalidArgument(const std::string& message)
61  : ProcessError(message) {}
62 };
63 
64 
69 class EmptyData : public ProcessError {
70 public:
73  : ProcessError("Empty Data") {}
74 };
75 
76 
82 class FormatException : public ProcessError {
83 public:
85  FormatException(const std::string& msg)
86  : ProcessError(msg) {}
87 };
88 
89 
97 public:
99  NumberFormatException(const std::string& data)
100  : FormatException("Invalid Number Format '" + data + "'") {}
101 };
102 
103 
110 public:
112  BoolFormatException(const std::string& data)
113  : FormatException("Invalid Bool Format '" + data + "'") {}
114 };
115 
116 
123 public:
126  : ProcessError("Out Of Bounds") {}
127 };
128 
129 
135 class UnknownElement : public ProcessError {
136 public:
139  : ProcessError("Unknown Element") {}
140 
142  UnknownElement(const std::string& msg)
143  : ProcessError(msg) {}
144 };
145 
146 
147 class IOError : public ProcessError {
148 public:
150  IOError(const std::string& message)
151  : ProcessError(message) {}
152 };
153 
155 #ifdef MSVC_TEST_SERVER
156 #ifdef _DEBUG
157 #define SOFT_ASSERT(expr) if (!(expr)) {throw ProcessError("should not happen");}
158 #else
159 #define SOFT_ASSERT(expr)
160 #endif
161 #else
162 #define SOFT_ASSERT(expr) assert(expr);
163 #endif
164 
165 #endif
166 
167 /****************************************************************************/
ProcessError(const std::string &msg)
constructor
OutOfBoundsException()
constructor
InvalidArgument(const std::string &message)
constructor
IOError(const std::string &message)
constructor
UnknownElement(const std::string &msg)
constructor
BoolFormatException(const std::string &data)
constructor
EmptyData()
constructor
FormatException(const std::string &msg)
constructor
NumberFormatException(const std::string &data)
constructor
ProcessError()
constructor
UnknownElement()
constructor