diff --git a/src/DataTree.hh b/src/DataTree.hh index 8502f3a82f3f0cdb476d8092c3edbecfe0ef9a48..57800d855a8faa0abb24abe66e6e22d824aba875 100644 --- a/src/DataTree.hh +++ b/src/DataTree.hh @@ -302,9 +302,13 @@ public: }; //! Raised when a trend is declared twice - struct TrendException + class TrendException : public std::exception { - string name; + private: + const string name; + + public: + TrendException(string name_arg) : name(name_arg) {} }; // Returns the derivation ID, or throws an exception if the derivation ID does not exist @@ -353,10 +357,14 @@ public: return false; }; - struct UnknownLocalVariableException + class UnknownLocalVariableException : public std::exception { + private: //! Symbol ID int id; + + public: + UnknownLocalVariableException(int id_arg) : id(id_arg) {} }; [[nodiscard]] expr_t diff --git a/src/EquationTags.hh b/src/EquationTags.hh index 998857cb2dfdf7c71c758784d01414e6cdfccc41..e08bcab7b075ac7d521c2a3e5f51b64999585dfa 100644 --- a/src/EquationTags.hh +++ b/src/EquationTags.hh @@ -33,6 +33,18 @@ private: map<int, map<string, string>> eqn_tags; public: + class TagNotFoundException : public std::exception + { + private: + const string key, value; + + public: + TagNotFoundException(const string key_arg, const string value_arg) : key(key_arg), + value(value_arg) + { + } + }; + // Add multiple equation tags for the given equation void add(int eqn, map<string, string> tags) diff --git a/src/ExternalFunctionsTable.hh b/src/ExternalFunctionsTable.hh index 40aadb519db2fc2562d6cb9f78b8e86a8ab86586..2815b1530b75f61fd0f34bac7faeb2050e288160 100644 --- a/src/ExternalFunctionsTable.hh +++ b/src/ExternalFunctionsTable.hh @@ -33,10 +33,14 @@ class ExternalFunctionsTable { public: //! Thrown when trying to access an unknown symbol (by id) - struct UnknownExternalFunctionSymbolIDException + class UnknownExternalFunctionSymbolIDException : public std::exception { + private: //! Symbol ID int id; + + public: + UnknownExternalFunctionSymbolIDException(int id_arg) : id(id_arg) {} }; /* For all arguments, -2 means not set diff --git a/src/SymbolTable.hh b/src/SymbolTable.hh index 01bbf91fe62051f1f0e3a1c49b6c093f8bb95fcb..7adbca7fe6b692ceeb1944ccaa5cc3b71ae85d9b 100644 --- a/src/SymbolTable.hh +++ b/src/SymbolTable.hh @@ -152,36 +152,63 @@ private: public: //! Thrown when trying to access an unknown symbol (by name) - struct UnknownSymbolNameException + class UnknownSymbolNameException : public std::exception { + private: //! Symbol name const string name; + + public: + UnknownSymbolNameException(const string name_arg) : name(name_arg) {} }; //! Thrown when trying to access an unknown symbol (by id) - struct UnknownSymbolIDException + class UnknownSymbolIDException : public std::exception { + private: //! Symbol ID const int id; + + public: + UnknownSymbolIDException(const int id_arg) : id(id_arg) {} }; //! Thrown when trying to access an unknown type specific ID - struct UnknownTypeSpecificIDException + class UnknownTypeSpecificIDException : public std::exception { + private: const int tsid; const SymbolType type; + + public: + UnknownTypeSpecificIDException(int tsid_arg, SymbolType type_arg) : tsid(tsid_arg), + type(type_arg) + { + } }; /* Thrown when requesting the type specific ID of a symbol which doesn’t have one */ - struct NoTypeSpecificIDException + class NoTypeSpecificIDException : public std::exception { + private: + //! Symbol ID const int symb_id; + + public: + NoTypeSpecificIDException(int symb_id_arg) : symb_id(symb_id_arg) {} }; //! Thrown when trying to declare a symbol twice - struct AlreadyDeclaredException + class AlreadyDeclaredException : public std::exception { + private: //! Symbol name const string name; //! Was the previous declaration done with the same symbol type ? const bool same_type; + + public: + AlreadyDeclaredException(string name_arg, bool same_type_arg) : name(name_arg), + same_type(same_type_arg) + { + } }; //! Thrown when table is frozen and trying to modify it class FrozenException