PStack
2.0
Stack trace printer for MSVC and GCC binaries
|
Base exception class from which all PSystem exceptions must inherit. More...
#include <base_exception.hpp>
Construction / Destruction | |
base_exception (std::string file, std::string function, uint32_t line) noexcept | |
Construct a base_exception instance with no message. More... | |
template<typename... MessageArgs> | |
base_exception (std::string file, std::string function, uint32_t line, MessageArgs &&...message) noexcept | |
Construct a base_exception instance with a formatted message. More... | |
virtual | ~base_exception () noexcept |
Destroy the exception (supports run-time polymorphism). | |
Virtual Method Overrides | |
virtual char const * | what () const noexcept override |
Return a message describing the exception that occurred. More... | |
Public Accessors | |
std::string const & | function () const noexcept |
Return the function where the exception occurred. More... | |
uint32_t | line_number () const noexcept |
Return the line on which the exception occurred. More... | |
std::string const & | source_file () const noexcept |
Return the name of the source file where the exception occurred. More... | |
Private Utilities | |
static std::string | format_message (char const *msg,...) noexcept |
A functional sprintf() replacement. More... | |
Member Data | |
std::string const | m_what |
A message describing the exception condition. | |
std::string const | m_function |
The function where the exception occurred. | |
uint32_t const | m_line_number |
The line number (in m_source_file) where the exception occurred. | |
std::string const | m_source_file |
The source file where the exception occurred. | |
Additional Inherited Members | |
Protected Member Functions inherited from psystem::not_assignable | |
not_assignable & | operator= (not_assignable const &) const =delete |
Delete the basic assignment operator. | |
constexpr | not_assignable () noexcept |
A simple CTOR suitable for noexcept and constexpr uses. | |
~not_assignable () noexcept | |
A simple CTOR suitable for noexcept uses. | |
Base exception class from which all PSystem exceptions must inherit.
This exception should never be thrown directly. It provides base functionality for all exceptions raised in PSystem-based applications. It is important to note that this derives from std::exception
, and applications should not throw something unless it derives from this (unless they want to see std::terminate
get called).
Derived classes may allow construction with no message, a simple text message, or a printf
style formatted message. Here is a simple example:
|
protectednoexcept |
Construct a base_exception instance with no message.
[in] | file | The source file where the exception occurred. |
[in] | function | The function in the source where the exception occurred. |
[in] | line | The line in file where the exception occurred. |
|
inlineprotectednoexcept |
Construct a base_exception instance with a formatted message.
[in] | file | The source file where the exception occurred. |
[in] | function | The function in the source where the exception occurred. |
[in] | line | The line in file where the exception occurred. |
[in] | message | This should be in a printf message/args style calling convention. |
|
staticprivatenoexcept |
A functional sprintf()
replacement.
This method is slightly more useful to us than sprintf()
because it returns a std::string
directly. This lets us skip all the details of finding the right size for an output buffer, allocating it, passing it around, and so on. All we're really interested in is a std::string
.
[in] | msg | The printf format string. |
[in] | ... | A variable length cstdarg argument pack used to populate the result, given msg . |
This could be implemented with perfect forwarding, but I don't want to include that much implementation detail in the header. With a non-template function, I can keep the definition away from every compilation unit.
|
noexcept |
Return the function where the exception occurred.
|
noexcept |
Return the line on which the exception occurred.
|
noexcept |
Return the name of the source file where the exception occurred.
|
overridevirtualnoexcept |
Return a message describing the exception that occurred.
Reimplemented in psystem::exception::system_exception.