Container System 0.1.0
High-performance C++20 type-safe container framework with SIMD-accelerated serialization
Loading...
Searching...
No Matches
error_handling_example.cpp File Reference
#include "container.h"
#include <kcenon/container/container/error_codes.h>
#include <iostream>
#include <string>
Include dependency graph for error_handling_example.cpp:

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )

Definition at line 23 of file error_handling_example.cpp.

24{
25 std::cout << "=== Error Handling Example ===" << std::endl;
26
27 // 1. Error code message lookup
28 std::cout << "\n1. Error code messages:" << std::endl;
29 std::cout << " Code 101: " << error_codes::get_message(101) << std::endl;
30 std::cout << " Code 201: " << error_codes::get_message(201) << std::endl;
31 std::cout << " Code 301: " << error_codes::get_message(301) << std::endl;
32
33 // 2. Error categories
34 std::cout << "\n2. Error categories:" << std::endl;
35 std::cout << " 101 is value error: " << (error_codes::is_value_error(101) ? "yes" : "no")
36 << std::endl;
37 std::cout << " 201 is serialization: "
38 << (error_codes::is_serialization_error(201) ? "yes" : "no") << std::endl;
39 std::cout << " 301 is validation: " << (error_codes::is_validation_error(301) ? "yes" : "no")
40 << std::endl;
41 std::cout << " 401 is resource: " << (error_codes::is_resource_error(401) ? "yes" : "no")
42 << std::endl;
43 std::cout << " 501 is thread: " << (error_codes::is_thread_error(501) ? "yes" : "no")
44 << std::endl;
45
46 // 3. Category lookup
47 std::cout << "\n3. Category names:" << std::endl;
48 std::cout << " Code 101 category: " << error_codes::get_category(101) << std::endl;
49 std::cout << " Code 201 category: " << error_codes::get_category(201) << std::endl;
50 std::cout << " Code 301 category: " << error_codes::get_category(301) << std::endl;
51
52 // 4. Formatted error messages
53 std::cout << "\n4. Formatted messages:" << std::endl;
54 auto msg = error_codes::make_message(101, "username");
55 std::cout << " " << msg << std::endl;
56
57 std::cout << "\nDone." << std::endl;
58 return 0;
59}