MarlinMT  0.1.0
Types.h
Go to the documentation of this file.
1 #pragma once
2 
4 
5 // -- std includes
6 #include <exception>
7 #include <string>
8 #include <string_view>
9 
10 #define MARLIN_BOOK_THROW( message ) \
11  throw marlinmt::book::exceptions::BookStoreException( \
12  __LINE__, __FUNCTION__, __FILE__, message );
13 
14 namespace marlinmt {
15  namespace book {
16  namespace exceptions {
17  class BookStoreException : public std::exception {
18  public:
19  BookStoreException() = delete;
20  BookStoreException(const BookStoreException&) = default;
21 
22  BookStoreException(unsigned int line, const char * func, const char * fname,
23  const std::string_view& message) ;
24 
25  const char* what() const noexcept override ;
26  private:
27  const std::string _message;
28  };
29 
30 
31  inline BookStoreException::BookStoreException(unsigned int line,
32  const char * func,
33  const char * fname,
34  const std::string_view& message)
35  : _message{
36  std::string(fname)
37  + " (l." + std::to_string(line) + ") in "
38  + func + ": " + std::string(message)
39  } {}
40 
41  inline const char* BookStoreException::what() const noexcept {
42  return _message.c_str();
43  }
44  } // end namespace exceptions
45  } // end namespace book
46 } // end namespace marlinmt
47 
48 
const char * what() const noexcept override
Definition: Types.h:41