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 /****************************************************************************/
17 // Exceptions for used by some utility classes
18 /****************************************************************************/
19 #ifndef UtilExceptions_h
20 #define UtilExceptions_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 
27 #include <string>
28 #include <stdexcept>
29 
30 
31 // ===========================================================================
32 // class definitions
33 // ===========================================================================
39 class ProcessError : public std::runtime_error {
40 public:
43  : std::runtime_error("Process Error") {}
44 
46  ProcessError(const std::string& msg)
47  : std::runtime_error(msg) {}
48 };
49 
50 
56 class InvalidArgument : public ProcessError {
57 public:
59  InvalidArgument(const std::string& message)
60  : ProcessError(message) {}
61 };
62 
63 
68 class EmptyData : public ProcessError {
69 public:
72  : ProcessError("Empty Data") {}
73 };
74 
75 
81 class FormatException : public ProcessError {
82 public:
84  FormatException(const std::string& msg)
85  : ProcessError(msg) {}
86 };
87 
88 
96 public:
98  NumberFormatException(const std::string& data)
99  : FormatException("Invalid Number Format '" + data + "'") {}
100 };
101 
102 
109 public:
111  TimeFormatException(const std::string& data)
112  : FormatException("Invalid Time Format '" + data + "'") {}
113 };
114 
115 
122 public:
124  BoolFormatException(const std::string& data)
125  : FormatException("Invalid Bool Format '" + data + "'") {}
126 };
127 
128 
135 public:
138  : ProcessError("Out Of Bounds") {}
139 };
140 
141 
147 class UnknownElement : public ProcessError {
148 public:
151  : ProcessError("Unknown Element") {}
152 
154  UnknownElement(const std::string& msg)
155  : ProcessError(msg) {}
156 };
157 
161 class IOError : public ProcessError {
162 public:
164  IOError(const std::string& message)
165  : ProcessError(message) {}
166 };
167 
169 #ifdef MSVC_TEST_SERVER
170 #ifdef _DEBUG
171 #define SOFT_ASSERT(expr) if (!(expr)) {throw ProcessError("should not happen");}
172 #else
173 #define SOFT_ASSERT(expr)
174 #endif
175 #else
176 #define SOFT_ASSERT(expr) assert(expr);
177 #endif
178 
179 #endif
180 
181 /****************************************************************************/
NumberFormatException::NumberFormatException
NumberFormatException(const std::string &data)
constructor
Definition: UtilExceptions.h:98
UnknownElement::UnknownElement
UnknownElement()
constructor
Definition: UtilExceptions.h:150
EmptyData
Definition: UtilExceptions.h:68
NumberFormatException
Definition: UtilExceptions.h:95
InvalidArgument::InvalidArgument
InvalidArgument(const std::string &message)
constructor
Definition: UtilExceptions.h:59
ProcessError
Definition: UtilExceptions.h:39
OutOfBoundsException
Definition: UtilExceptions.h:134
ProcessError::ProcessError
ProcessError(const std::string &msg)
constructor
Definition: UtilExceptions.h:46
BoolFormatException::BoolFormatException
BoolFormatException(const std::string &data)
constructor
Definition: UtilExceptions.h:124
FormatException
Definition: UtilExceptions.h:81
FormatException::FormatException
FormatException(const std::string &msg)
constructor
Definition: UtilExceptions.h:84
BoolFormatException
Definition: UtilExceptions.h:121
ProcessError::ProcessError
ProcessError()
constructor
Definition: UtilExceptions.h:42
UnknownElement
Definition: UtilExceptions.h:147
TimeFormatException
Definition: UtilExceptions.h:108
OutOfBoundsException::OutOfBoundsException
OutOfBoundsException()
constructor
Definition: UtilExceptions.h:137
InvalidArgument
Definition: UtilExceptions.h:56
UnknownElement::UnknownElement
UnknownElement(const std::string &msg)
constructor
Definition: UtilExceptions.h:154
IOError
Definition: UtilExceptions.h:161
IOError::IOError
IOError(const std::string &message)
constructor
Definition: UtilExceptions.h:164
TimeFormatException::TimeFormatException
TimeFormatException(const std::string &data)
constructor
Definition: UtilExceptions.h:111
EmptyData::EmptyData
EmptyData()
constructor
Definition: UtilExceptions.h:71