EntropyEngine::Networking::Result
EntropyEngine::Networking::Result
Section titled “EntropyEngine::Networking::Result”Result type for operations that may fail. More…
#include <ErrorCodes.h>
Public Functions
Section titled “Public Functions”| Name | |
|---|---|
| T & | valueOrThrow() Get the value or throw on error. |
| bool | success() const Check if operation succeeded. |
| Result< T > | ok(T val) Create a successful result. |
| bool | failed() const Check if operation failed. |
| Result< T > | err(NetworkError err, std::string message ="") Create a failed result. |
Public Attributes
Section titled “Public Attributes”| Name | |
|---|---|
| T | value Result value (valid only if error == None). |
| std::string | errorMessage Optional detailed error message. |
| NetworkError | error Error code. |
Detailed Description
Section titled “Detailed Description”template <typename T >struct EntropyEngine::Networking::Result;Result type for operations that may fail.
Encapsulates a value and an error code. Check success() before accessing value.
auto result = someOperation();if (result.success()) { useValue(result.value);} else { handleError(result.error);}Public Functions Documentation
Section titled “Public Functions Documentation”function valueOrThrow
Section titled “function valueOrThrow”inline T & valueOrThrow()Get the value or throw on error.
Exceptions:
- std::runtime_error if operation failed
Return: The contained value
function success
Section titled “function success”inline bool success() constCheck if operation succeeded.
Return: true if no error occurred
function ok
Section titled “function ok”static inline Result< T > ok( T val)Create a successful result.
Parameters:
- val The result value
Return: Result with no error
function failed
Section titled “function failed”inline bool failed() constCheck if operation failed.
Return: true if an error occurred
function err
Section titled “function err”static inline Result< T > err( NetworkError err, std::string message ="")Create a failed result.
Parameters:
- err The error code
- message Optional error message
Return: Result with error
Public Attributes Documentation
Section titled “Public Attributes Documentation”variable value
Section titled “variable value”T value;Result value (valid only if error == None).
variable errorMessage
Section titled “variable errorMessage”std::string errorMessage;Optional detailed error message.
variable error
Section titled “variable error”NetworkError error;Error code.
Updated on 2026-01-26 at 17:14:35 -0500