Lightweight 0.20261105.1
Loading...
Searching...
No Matches
Lightweight::Driver::CallOutcome Struct Reference

Verdict of a non-throwing checked driver call, carrying the diagnostic that justifies a failure verdict whenever that failure was injected rather than real. More...

#include <Concept.hpp>

Public Member Functions

constexpr operator bool () const noexcept
 
template<typename ReadFromHandle >
requires std::is_invocable_r_v<SqlErrorInfo, ReadFromHandle const&>
SqlErrorInfo EffectiveError (ReadFromHandle const &readFromHandle) const
 The diagnostic describing this failure, from whichever source actually has one.
 

Public Attributes

bool succeeded {}
 Whether the checked call should be treated as having succeeded.
 
std::optional< SqlErrorInfo > injectedError {}
 

Detailed Description

Verdict of a non-throwing checked driver call, carrying the diagnostic that justifies a failure verdict whenever that failure was injected rather than real.

A bare bool is not enough here. When an installed fault source overrides a real success into a failure, the underlying driver call genuinely succeeded, so the handle holds no diagnostic records at all: a caller that recovers by inspecting the error (rather than merely branching on it) would read an empty or stale diagnostic off the handle and take the wrong recovery arm. Carrying the injected error alongside the verdict is what makes such an arm reachable from a test, which is the whole point of the seam.

Definition at line 75 of file Concept.hpp.

Member Function Documentation

◆ operator bool()

constexpr Lightweight::Driver::CallOutcome::operator bool ( ) const
inlineexplicitconstexprnoexcept
Returns
succeeded, so an outcome can be tested directly in an if.

Definition at line 86 of file Concept.hpp.

References succeeded.

◆ EffectiveError()

template<typename ReadFromHandle >
requires std::is_invocable_r_v<SqlErrorInfo, ReadFromHandle const&>
SqlErrorInfo Lightweight::Driver::CallOutcome::EffectiveError ( ReadFromHandle const &  readFromHandle) const
inline

The diagnostic describing this failure, from whichever source actually has one.

Parameters
readFromHandleInvoked only when the failure was not injected, to read the real handle's diagnostic (e.g. Driver::Diagnose or SqlConnection::LastError). Deliberately lazy: reading diagnostics off a handle is a driver round-trip, and there is nothing to read when the failure was injected.
Returns
The injected diagnostic when there is one, otherwise readFromHandle's result.

Definition at line 101 of file Concept.hpp.

References injectedError.

Member Data Documentation

◆ succeeded

bool Lightweight::Driver::CallOutcome::succeeded {}

Whether the checked call should be treated as having succeeded.

Definition at line 78 of file Concept.hpp.

Referenced by Lightweight::Driver::Sqlite3::CheckResult(), Lightweight::Driver::Sqlite3::CheckResult(), and operator bool().

◆ injectedError

std::optional<SqlErrorInfo> Lightweight::Driver::CallOutcome::injectedError {}

The injected diagnostic, engaged only when a fault source turned a real success into a failure. Never engaged for a genuine failure — that one's diagnostic is on the handle, where the caller can read it. Prefer EffectiveError over branching on this directly.

Definition at line 83 of file Concept.hpp.

Referenced by EffectiveError().


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