forb
exception.hpp
1 //
2 // Created by gabriele on 03/12/18.
3 //
4 
5 #ifndef FORB_EXCEPTION_H
6 #define FORB_EXCEPTION_H
7 
8 #include <string>
9 #include <exception>
10 
11 namespace forb {
13  class exception : public std::exception {
15  std::string _what;
16 
17  public:
20  explicit exception(const std::string &cause) : std::exception(), _what(cause) {};
21 
23  ~exception() override = default;
24 
26  exception(exception &&) = default;
27 
29  exception &operator=(exception &&) = default;
30 
32  exception(const exception &) = default;
33 
35  exception &operator=(const exception &) = default;
36 
38  const char *what() const noexcept override {
39  return _what.c_str();
40  }
41 
42  };
43 }
44 
45 
46 #endif //FORB_EXCEPTION_H
47 
This function implements a memcpy abstract that is valid also for volatile data.
Definition: base_skeleton.hpp:15
Custom exception type used in FORB library.
Definition: exception.hpp:13
~exception() override=default
Virtual destructor.
const char * what() const noexcept override
Returns the cause of the exception.
Definition: exception.hpp:38
exception(const std::string &cause)
Constructs a new exception; the first argument represents the action that was performed when the exce...
Definition: exception.hpp:20