|
Database System 0.1.0
Advanced C++20 Database System with Multi-Backend Support
|
Demonstrates the Result<T> error handling pattern used throughout the database_system API. More...
#include <iostream>#include <memory>#include <string>#include <variant>#include "database/database_manager.h"#include "database/core/database_context.h"
Go to the source code of this file.
Functions | |
| static void | print_error (const std::string &operation, const kcenon::common::error_info &err) |
| Helper to print a Result error. | |
| static void | demonstrate_connection_failure () |
| Demonstrates handling a connection failure gracefully. | |
| static void | demonstrate_query_errors (std::shared_ptr< database_manager > db) |
| Demonstrates handling query errors with Result<T>. | |
| static bool | demonstrate_chained_operations (std::shared_ptr< database_manager > db) |
| Demonstrates chaining operations with early return on failure. | |
| static void | demonstrate_last_error (std::shared_ptr< database_manager > db) |
| Demonstrates using last_error() for additional diagnostics. | |
| int | main () |
Demonstrates the Result<T> error handling pattern used throughout the database_system API.
This example shows how to:
Note: Parts of this example intentionally trigger errors to demonstrate the error handling paths. A running PostgreSQL server is required for full execution, but the patterns are useful even without one.
Definition in file error_handling.cpp.
|
static |
Demonstrates chaining operations with early return on failure.
Definition at line 113 of file error_handling.cpp.
References print_error().
Referenced by main().


|
static |
Demonstrates handling a connection failure gracefully.
Definition at line 46 of file error_handling.cpp.
References print_error().
Referenced by main().


|
static |
Demonstrates using last_error() for additional diagnostics.
Definition at line 164 of file error_handling.cpp.
Referenced by main().

|
static |
Demonstrates handling query errors with Result<T>.
Definition at line 73 of file error_handling.cpp.
References print_error().
Referenced by main().


| int main | ( | ) |
Definition at line 183 of file error_handling.cpp.
References demonstrate_chained_operations(), demonstrate_connection_failure(), demonstrate_last_error(), and demonstrate_query_errors().

|
static |
Helper to print a Result error.
The error type returned by Result<T>::error() is kcenon::common::error_info, which contains code, message, and module fields.
Definition at line 38 of file error_handling.cpp.
Referenced by demonstrate_chained_operations(), demonstrate_connection_failure(), and demonstrate_query_errors().
