2019-06-19 14:34:30 +02:00
|
|
|
/*
|
|
|
|
* Copyright © 2004-2011 Ondra Kamenik
|
2023-12-05 15:44:23 +01:00
|
|
|
* Copyright © 2019-2023 Dynare Team
|
2019-06-19 14:34:30 +02:00
|
|
|
*
|
|
|
|
* This file is part of Dynare.
|
|
|
|
*
|
|
|
|
* Dynare is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Dynare is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-06-09 17:33:48 +02:00
|
|
|
* along with Dynare. If not, see <https://www.gnu.org/licenses/>.
|
2019-06-19 14:34:30 +02:00
|
|
|
*/
|
2009-09-08 15:55:19 +02:00
|
|
|
|
|
|
|
#ifndef SYLV_EXCEPTION_H
|
|
|
|
#define SYLV_EXCEPTION_H
|
|
|
|
|
2019-01-16 17:52:16 +01:00
|
|
|
#include <string>
|
|
|
|
|
2019-01-25 15:29:14 +01:00
|
|
|
class SylvException
|
2017-05-16 16:30:27 +02:00
|
|
|
{
|
2009-09-08 15:55:19 +02:00
|
|
|
protected:
|
2019-01-16 17:52:16 +01:00
|
|
|
std::string file;
|
2017-05-16 16:30:27 +02:00
|
|
|
int line;
|
2023-11-29 19:00:21 +01:00
|
|
|
|
2009-09-08 15:55:19 +02:00
|
|
|
public:
|
2019-01-16 17:52:16 +01:00
|
|
|
SylvException(std::string f, int l);
|
2019-01-15 18:55:09 +01:00
|
|
|
virtual ~SylvException() = default;
|
2017-05-16 16:30:27 +02:00
|
|
|
void printMessage() const;
|
2023-12-05 15:44:23 +01:00
|
|
|
[[nodiscard]] virtual std::string getMessage() const;
|
2009-09-08 15:55:19 +02:00
|
|
|
};
|
|
|
|
|
2017-05-16 16:30:27 +02:00
|
|
|
class SylvExceptionMessage : public SylvException
|
|
|
|
{
|
2019-01-16 17:52:16 +01:00
|
|
|
std::string message;
|
2023-11-29 19:00:21 +01:00
|
|
|
|
2009-09-08 15:55:19 +02:00
|
|
|
public:
|
2019-01-16 17:52:16 +01:00
|
|
|
SylvExceptionMessage(std::string f, int l, std::string mes);
|
2023-12-05 15:44:23 +01:00
|
|
|
[[nodiscard]] std::string getMessage() const override;
|
2009-09-08 15:55:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
// define macros:
|
2017-05-16 16:30:27 +02:00
|
|
|
#define SYLV_MES_EXCEPTION(mes) (SylvExceptionMessage(__FILE__, __LINE__, mes))
|
2009-09-08 15:55:19 +02:00
|
|
|
|
|
|
|
#endif /* SYLV_EXCEPTION_H */
|