nsbaci 1.0
Loading...
Searching...
No Matches
nsbaci::BaseResult Struct Reference

Base result structure for all service operations. More...

#include <baseResult.h>

Inheritance diagram for nsbaci::BaseResult:

Public Member Functions

 BaseResult ()
 Default constructor creates a successful result.
 BaseResult (std::vector< nsbaci::Error > errs)
 Constructs a result from a vector of errors.
 BaseResult (nsbaci::Error error)
 Constructs a failed result from a single error.
 BaseResult (BaseResult &&) noexcept=default
BaseResultoperator= (BaseResult &&) noexcept=default
 BaseResult (const BaseResult &)=default
BaseResultoperator= (const BaseResult &)=default

Public Attributes

bool ok
 True if the operation succeeded.
std::vector< nsbaci::Errorerrors
 Errors encountered (empty if ok is true).

Detailed Description

Base result structure for all service operations.

BaseResult provides a common interface for service operation results, encapsulating success/failure status and any associated error information. All service-specific result types should inherit from this base to ensure consistent error handling patterns throughout the application.

Invariant
If ok is false, errors vector contains at least one error.
If ok is true, errors vector is empty.

Usage example:

BaseResult result = someService.doOperation();
if (!result.ok) {
for (const auto& err : result.errors) {
handleError(err);
}
}
bool ok
True if the operation succeeded.
Definition baseResult.h:85
BaseResult()
Default constructor creates a successful result.
Definition baseResult.h:60
std::vector< nsbaci::Error > errors
Errors encountered (empty if ok is true).
Definition baseResult.h:87

Constructor & Destructor Documentation

◆ BaseResult() [1/2]

nsbaci::BaseResult::BaseResult ( std::vector< nsbaci::Error > errs)
inlineexplicit

Constructs a result from a vector of errors.

If the error vector is empty, the result is considered successful.

Parameters
errsVector of errors encountered during the operation.

◆ BaseResult() [2/2]

nsbaci::BaseResult::BaseResult ( nsbaci::Error error)
inlineexplicit

Constructs a failed result from a single error.

Parameters
errorThe error that caused the operation to fail.

The documentation for this struct was generated from the following file: