fire v0.19.0
Framework for sImulation and Reconstruction of Events
Exception.h
1#ifndef FIRE_EXCEPTION_EXCEPTION_H
2#define FIRE_EXCEPTION_EXCEPTION_H
3
4/*~~~~~~~~~~~~~~~~*/
5/* C++ StdLib */
6/*~~~~~~~~~~~~~~~~*/
7#include <exception>
8#include <string>
9
10namespace fire {
11
18class Exception : public std::exception {
19 public:
25 Exception() noexcept {}
26
37 Exception(const std::string& cat, const std::string& msg, bool build_trace = true) noexcept;
38
42 virtual ~Exception() = default;
43
48 const std::string& category() const noexcept { return category_; }
49
54 const std::string& message() const noexcept { return message_; }
55
64 const std::string& trace() const noexcept { return stack_trace_; }
65
70 virtual const char *what() const noexcept override {
71 return message_.c_str();
72 }
73
74 private:
81};
82} // namespace fire
83
84#endif
T c_str(T... args)
Standard base exception class with some useful output information.
Definition: Exception.h:18
const std::string & message() const noexcept
Get the message of the exception.
Definition: Exception.h:54
const std::string & trace() const noexcept
Get the stack trace.
Definition: Exception.h:64
Exception() noexcept
Empty constructor.
Definition: Exception.h:25
std::string stack_trace_
the stored stack trace at the throw point (if created)
Definition: Exception.h:80
virtual const char * what() const noexcept override
The error message.
Definition: Exception.h:70
std::string category_
the category of this exception
Definition: Exception.h:76
const std::string & category() const noexcept
get the category of this exception
Definition: Exception.h:48
std::string message_
the error message to print with this exception
Definition: Exception.h:78
STL namespace.