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.dev/sumo
3 // Copyright (C) 2001-2024 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 #include "Translation.h"
29 
30 
31 // ===========================================================================
32 // class definitions
33 // ===========================================================================
39 class ProcessError : public std::runtime_error {
40 public:
43  : std::runtime_error(TL("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(TL("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(TLF("Invalid Number Format %", data)) {}
100 };
101 
102 
109 public:
111  TimeFormatException(const std::string& data)
112  : FormatException(TLF("Invalid Time Format %", data)) {}
113 };
114 
115 
122 public:
124  BoolFormatException(const std::string& data)
125  : FormatException(TLF("Invalid Bool Format %", data)) {}
126 };
127 
128 
135 public:
137  OutOfBoundsException(const std::string& msg = TL("Out Of Bounds"))
138  : ProcessError(msg) {}
139 };
140 
141 
147 class UnknownElement : public ProcessError {
148 public:
151  : ProcessError(TL("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(TL("should not happen"));}
172 #else
173 #define SOFT_ASSERT(expr)
174 #endif
175 #else
176 #define SOFT_ASSERT(expr) assert(expr);
177 #endif
#define TL(string)
Definition: MsgHandler.h:315
#define TLF(string,...)
Definition: MsgHandler.h:317
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(const std::string &msg=TL("Out Of Bounds"))
constructor
ProcessError()
constructor
ProcessError(const std::string &msg)
constructor
TimeFormatException(const std::string &data)
constructor
UnknownElement(const std::string &msg)
constructor
UnknownElement()
constructor
Definition: json.hpp:4471