/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2026 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file UtilExceptions.h14/// @author Daniel Krajzewicz15/// @author Christian Roessel16/// @author Michael Behrisch17/// @author Felix Brack18/// @date Mon, 17 Dec 200119///20// Exceptions for used by some utility classes21/****************************************************************************/22#pragma once23#include <config.h>2425#include <string>26#include <stdexcept>2728#include "Translation.h"2930// ===========================================================================31// class definitions32// ===========================================================================33/**34* ProcessError35* The base class for all exceptions in SUMO. The reason itself can either be36* reported before throwing the exception or in the message parameter.37*/38class ProcessError : public std::runtime_error {3940public:41/// @brief constructor42ProcessError();4344/// @brief parameter constructor45ProcessError(const std::string& msg);4647/// @brief get trace48const std::string& getTrace() const;4950private:51/// @brief exception trace52std::string myTrace;5354/// @brief process trace55void processTrace();56};575859/**60* InvalidArgument61* Thrown when an argument was not proper in the current context.62* A message will be supplied.63*/64class InvalidArgument : public ProcessError {6566public:67/// @brief constructor68InvalidArgument(const std::string& message);69};707172/**73* EmptyData74* Thrown when data required by a method is missing75*/76class EmptyData : public ProcessError {7778public:79/// @brief constructor80EmptyData();81};828384/**85* FormatException86* Thrown when a string that shall be converted into87* something else contained the wrong characters88*/89class FormatException : public ProcessError {9091public:92/// @brief constructor93FormatException(const std::string& msg);94};959697/**98* NumberFormatException99* Thrown when the string that shall be converted into a100* numerical representation has any other characters then101* digits and a dot102*/103class NumberFormatException : public FormatException {104105public:106/// @brief constructor107NumberFormatException(const std::string& data);108};109110111/**112* TimeFormatException113* Thrown when the string that shall be converted into a114* time representation HH:MM:SS isn't valid115*/116class TimeFormatException : public FormatException {117118public:119/// @brief constructor120TimeFormatException(const std::string& data);121};122123124/**125* BoolFormatException126* Thrown when the string that shall be converted into a127* boolean does not match128*/129class BoolFormatException : public FormatException {130131public:132/// @brief constructor133BoolFormatException(const std::string& data);134};135136137/**138* OutOfBoundsException139* Thrown when an array element out of the array's140* bounderies is accessed141*/142class OutOfBoundsException : public ProcessError {143144public:145/// @brief constructor146OutOfBoundsException(const std::string& msg = TL("Out Of Bounds"));147};148149150/**151* UnknownElement152* Thrown when a named element is tried to be accessed153* which is not known to the container154*/155class UnknownElement : public ProcessError {156157public:158/// @brief constructor159UnknownElement();160161/// @brief constructor162UnknownElement(const std::string& msg);163};164165/**166* IOError167*/168class IOError : public ProcessError {169170public:171/// @brief constructor172IOError(const std::string& message);173};174175/// define SOFT_ASSERT raise an assertion in debug mode everywhere except on the windows test server176#ifdef MSVC_TEST_SERVER177#ifdef _DEBUG178#define SOFT_ASSERT(expr) if (!(expr)) {throw ProcessError(TL("should not happen"));}179#else180#define SOFT_ASSERT(expr)181#endif182#else183#define SOFT_ASSERT(expr) assert(expr);184#endif185186187