FCF 2.0 development in progress...
> > > > > >
[News] [C++ Libraries API] [C++ Downloads] [Donate to the project] [Contacts]

info() method from fcf::Exception class

std::string info() const

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 a human-readable summary of the exception information.

The info method provides a condensed, human-readable summary of the exception's details. It is designed for quick inspection of the error state without the verbosity of the full method.

The output generated by info is structured into three clear components:

  • Error Identity: Displays the short name of the exception (e.g., "FCF_LOGIC").
  • Message: Displays the resolved, formatted error message, including any substituted arguments.
  • Position: Displays the file name and line number where the exception was thrown.

Result
std::string
- A string containing the summarized exception information.

Example: Using info() for concise error reporting

Demonstrating how to use the info method to print a compact error summary.

#include <iostream> #define FCF_BASIS_IMPLEMENTATION #include <fcfBasis/basis.hpp> int main() { try { // 1. Throw a formatted exception throw fcf::LogicException(__FILE__, __LINE__, "Unexpected state detected"); } catch (const fcf::Exception& e) { // 2. Retrieve and print the info summary // This will output a structured summary instead of just the raw message std::cout << e.info() << std::endl; } return 0; }

Output:

Error: FCF_LOGIC Message: Logic error: Unexpected state detected Position: /home/user/application/main.cpp:8

The info method provides a clean, structured way to view the most important error details at a glance.