![]() |
UtilsLite
Utilities for C++ programming
|
Custom runtime error class for handling runtime exceptions. More...
#include <Utils_fmt.hh>
Public Member Functions | |
Runtime_Error (string_view reason, string_view file, int line) | |
Constructs a Runtime_Error instance with a given reason. | |
char const * | what () const noexcept override |
Returns a C-style string describing the error. | |
Custom runtime error class for handling runtime exceptions.
This class extends the standard std::runtime_error
to include additional context information, specifically the file name and line number where the error occurred. It provides constructors that accept a reason for the error and formats the error message accordingly.
Usage
|
inlineexplicit |
Constructs a Runtime_Error instance with a given reason.
This constructor initializes the error with a specified reason, the file where the error occurred, and the line number. It formats the error message accordingly.
reason | A string that describes the reason for the error. |
file | The name of the file where the error occurred. |
line | The line number in the file where the error occurred. |
|
overridenoexcept |
Returns a C-style string describing the error.
This method overrides the what()
method from std::runtime_error
to provide a more detailed error message, including the reason for the error, the file name, and the line number.