Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef EXCEPTIONS_H
- #define EXCEPTIONS_H
- #include <exception>
- #include <string>
- using namespace std;
- class BaseException : public exception
- {
- public:
- BaseException() : msg(""), func(""), file(""), line(0){}
- explicit BaseException(const char* error, const char* funcName, const char* fileName, int lineError):msg(error), func(funcName), file(fileName), line(lineError){}
- virtual const char* what()
- {
- std::string message = "";
- message += msg;
- message += ". Файл: ";
- message += file;
- message += ". Строка: ";
- message += std::to_string(line);
- message += ". Функция: ";
- message += func;
- return message.c_str();
- }
- const char* get_func() const
- {
- return func;
- }
- protected:
- const char* msg;
- const char* func;
- const char* file;
- const int line;
- };
- class NullPointerException: public BaseException
- {
- public:
- explicit NullPointerException(const char* funcName, const char* fileName, int lineError)
- : BaseException("Null Pointer Exception at", funcName, fileName, lineError){}
- };
- #endif // MY_EXCEPTION_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement