Class: fcf::Exception
Package: fcfBasis
File:
bits/PartException/ExceptionDecl.hpp
(
link_to_the_declaration_in_the_file
)
Implementation file:
bits/PartException/Exception.hpp
(
link_to_the_implementation_in_the_file
)
Available from version: 1.0.1
Returns the dynamically formatted error message string.
The message method returns the final, human-readable error message after all template placeholders have been resolved.
When an exception is constructed using a message pattern (e.g., "Error in ${{1}}$ with value ${{2}}$"), the actual values are not processed immediately. Instead, they are stored as arguments. The message method performs the heavy lifting of string interpolation only when it is called. The method is thread-safe.
Result
std::string
- A string containing the fully interpolated error message.
Example: Dynamic message formatting
Demonstrating how template placeholders are substituted with actual argument values when calling the message method.
#include <iostream>
#define FCF_BASIS_IMPLEMENTATION
#include <fcfBasis/basis.hpp>
int main() {
try {
// 1. Throw an exception with a pattern and arguments
// The pattern uses ${{1}}$ and ${{2}}$ as placeholders
throw fcf::LogicException(
__FILE__,
__LINE__,
"Operation failed for an item");
} catch (const fcf::Exception& e) {
// 2. Retrieve the formatted message
// The message() method resolves the placeholders into the final string
std::cout << "Resolved Message: " << e.message() << std::endl;
}
return 0;
}
Output:
Resolved Message: Logic error: Operation failed for an item
The message method is the key component for turning technical error patterns into meaningful, human-readable information.