A simple scripting language in C++
Szontágh Ferenc
2025-04-19 571a9a1bafe0d8adddf3141f82213a47e4568baa
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#ifndef BASE_EXCEPTION_HPP
#define BASE_EXCEPTION_HPP
 
#include <string>
 
class BaseException : public std::exception {
  public:
    BaseException(const std::string & msg, const std::string & context = "") : rawMessage_(msg), context_(context) {
        formattedMessage_ = formatMessage();
    }
    BaseException() = default;
    BaseException(const BaseException&) = default;
 
 
    const char * what() const noexcept override { return formattedMessage_.c_str(); }
 
    virtual std::string formatMessage() const { return "[BaseException] " + context_ + ": " + rawMessage_; }
 
  protected:
    std::string rawMessage_;
    std::string context_;
    std::string formattedMessage_;
};
 
#endif  // BASE_EXCEPTION_HPP