pflib v2.7.0-1-gd371ab6a
Polarfire Interaction Library
Exception.h
1#ifndef PFLIB_EXCEPTION_H_
2#define PFLIB_EXCEPTION_H_
3
4#include <exception>
5#include <string>
6
7namespace pflib {
8
12class Exception : public std::exception {
13 public:
19 Exception() throw() {}
20
30 const std::string &module, int line, const std::string &function)
31 : name_{name},
35 line_{line} {
36 }
37
41 virtual ~Exception() throw() {}
42
47 const std::string &name() const throw() { return name_; }
48
53 const std::string &message() const throw() { return message_; }
54
59 const std::string &module() const throw() { return module_; }
60
65 const std::string &function() const throw() { return function_; }
66
71 int line() const throw() { return line_; }
72
77 virtual const char *what() const throw() { return message_.c_str(); }
78
79 private:
80
83
86
89
92
94 int line_{0};
95
96};
97
98}
99
109#define PFEXCEPTION_RAISE(EXCEPTION, MSG) \
110 throw pflib::Exception(EXCEPTION, MSG, __FILE__, __LINE__, \
111 __FUNCTION__)
112
113#endif // PFLIB_EXCEPTION_H_
T c_str(T... args)
PFlib.
Definition: Exception.h:12
const std::string & module() const
Get the source filename where the exception occurred.
Definition: Exception.h:59
std::string name_
Exception name.
Definition: Exception.h:82
std::string message_
Error message.
Definition: Exception.h:85
const std::string & function() const
Get the function name where the exception occurred.
Definition: Exception.h:65
int line_
Source line number where the exception occurred.
Definition: Exception.h:94
int line() const
Get the source line number where the exception occurred.
Definition: Exception.h:71
std::string module_
Source filename where the exception occurred.
Definition: Exception.h:88
const std::string & message() const
Get the message of the exception.
Definition: Exception.h:53
Exception()
Empty constructor.
Definition: Exception.h:19
virtual const char * what() const
The error message.
Definition: Exception.h:77
virtual ~Exception()
Class destructor.
Definition: Exception.h:41
Exception(const std::string &name, const std::string &message, const std::string &module, int line, const std::string &function)
Class constructor.
Definition: Exception.h:29
std::string function_
Function name where the exception occurred.
Definition: Exception.h:91
const std::string & name() const
Get the name of the exception.
Definition: Exception.h:47
Polarfire Interaction Library.
Definition: Backend.h:8