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

exception from class fcf::Error

Property: exception = 0

Type: Exception*

Class: fcf::Error

Package: fcfBasis

File: bits/PartException/ErrorDecl.hpp ( link_to_the_declaration_in_the_file )

Available from version: 1.0.1

A pointer to an fcf::Exception object that holds the detailed error metadata.

The exception property is a pointer to an fcf::Exception instance. While the error property provides a quick access to the error's name, the exception pointer allows access to the full context of the error.

This includes the complete formatted message, the file and line number where the error was raised, and any additional arguments captured during the raise call.

To use this property effectively, you should pass a pointer to an existing fcf::Exception object to the fcf::Error constructor. When raise is called, the data will be written into the object pointed to by this property.

Example: Accessing Detailed Exception Metadata

Demonstrating how to use the exception pointer to retrieve the full, formatted error message and position information.

#define FCF_BASIS_IMPLEMENTATION #include <iostream> #include <fcfBasis/basis.hpp> // Define a custom exception that takes one argument FCF_EXCEPTION_DECLARE(DetailException, "DETAIL_ERR", "Detailed error message: ${{1}}$", 1); int main() { // 1. Create an exception object that will hold the error data fcf::Exception myEx; // 2. Initialize the Error structure with a pointer to our exception object fcf::Error err(&myEx); // 3. Raise the error // This call populates 'myEx' with the details of 'DetailException' err.raise<DetailException>(__FILE__, __LINE__, "Specific details provided here"); if (err) { std::cout << "Error detected!" << std::endl; // 4. Use the 'exception' pointer to access the full error context if (err.exception) { std::cout << "Full Error Info:\n" << err.exception->full() << std::endl; } } return 0; }

Output:

Error detected! Full Error Info: Error: DETAIL_ERR Message: Detailed error message: Specific details provided here Position: /home/user/application/main.cpp:17