forb
exception.hpp
1 //
2 // Created by gabriele on 01/12/18.
3 //
4 
5 #ifndef FORBCC_EXCEPTION_H
6 #define FORBCC_EXCEPTION_H
7 
8 #include <string>
9 #include <exception>
10 
11 namespace forbcc {
12 
14  class exception : public std::exception {
16  std::string _what;
17 
18  public:
21  exception(const std::string &when, const std::string &cause)
22  : std::exception() {
23  _what = "Error during " + when + ": " + cause + ".";
24  };
25 
27  ~exception() override = default;
28 
30  exception(exception &&) = default;
31 
33  exception &operator=(exception &&) = default;
34 
36  exception(const exception &) = default;
37 
39  exception &operator=(const exception &) = default;
40 
42  const char *what() const noexcept override {
43  return _what.c_str();
44  }
45 
46  };
47 }
48 
49 
50 #endif //FORBCC_EXCEPTION_H
Definition: code_ostream.hpp:11
const char * what() const noexcept override
Returns the cause of the exception.
Definition: exception.hpp:42
Custom exception type used in the FORB IDL compiler.
Definition: exception.hpp:14
~exception() override=default
Virtual destructor.
exception(const std::string &when, const std::string &cause)
Constructs a new exception; the first argument represents the action that was performed when the exce...
Definition: exception.hpp:21