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-2018 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 #include <config.h>
28 
29 #include <string>
30 #include <stdexcept>
31 
32 
33 // ===========================================================================
34 // class definitions
35 // ===========================================================================
41 class ProcessError : public std::runtime_error {
42 public:
45  : std::runtime_error("Process Error") {}
46 
48  ProcessError(const std::string& msg)
49  : std::runtime_error(msg) {}
50 };
51 
52 
58 class InvalidArgument : public ProcessError {
59 public:
61  InvalidArgument(const std::string& message)
62  : ProcessError(message) {}
63 };
64 
65 
70 class EmptyData : public ProcessError {
71 public:
74  : ProcessError("Empty Data") {}
75 };
76 
77 
83 class FormatException : public ProcessError {
84 public:
86  FormatException(const std::string& msg)
87  : ProcessError(msg) {}
88 };
89 
90 
98 public:
100  NumberFormatException(const std::string& data)
101  : FormatException("Invalid Number Format '" + data + "'") {}
102 };
103 
104 
111 public:
113  BoolFormatException(const std::string& data)
114  : FormatException("Invalid Bool Format '" + data + "'") {}
115 };
116 
117 
124 public:
127  : ProcessError("Out Of Bounds") {}
128 };
129 
130 
136 class UnknownElement : public ProcessError {
137 public:
140  : ProcessError("Unknown Element") {}
141 
143  UnknownElement(const std::string& msg)
144  : ProcessError(msg) {}
145 };
146 
147 
148 class IOError : public ProcessError {
149 public:
151  IOError(const std::string& message)
152  : ProcessError(message) {}
153 };
154 
156 #ifdef MSVC_TEST_SERVER
157  #ifdef _DEBUG
158  #define SOFT_ASSERT(expr) if (!(expr)) {throw ProcessError("should not happen");}
159  #else
160  #define SOFT_ASSERT(expr)
161  #endif
162 #else
163  #define SOFT_ASSERT(expr) assert(expr);
164 #endif
165 
166 #endif
167 
168 /****************************************************************************/
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