Use Api::fail() for error returns (241 sites)

Mechanically convert std::unexpected(Api::Error(ErrorCode::X, msg[, src]))
to Api::fail(ErrorCode::X, msg[, src]) across Core. Pure syntax; forwards of
existing errors (std::unexpected(x.error())) are unchanged.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Opus 4.8 committed 2026-06-22 22:07:18 +03:00
1 parent f8757d6040
commit 23759899bb
14 files changed
+344 -435

No files matched your search

+10 -10
View File
@@ -27,8 +27,8 @@ namespace Echoion::Core
StateSerializer::deserialize(const Api::StateBlob& blob)
{
if (blob.data.empty()) {
return std::unexpected(Api::Error{Api::ErrorCode::InvalidArgument,
"Empty state blob"});
return Api::fail(Api::ErrorCode::InvalidArgument,
"Empty state blob");
}
// Convert blob to string
@@ -40,18 +40,18 @@ namespace Echoion::Core
// Check if version is supported
if (!isVersionSupported(dataVersion)) {
if (dataVersion > CURRENT_VERSION) {
return std::unexpected(Api::Error{
return Api::fail(
Api::ErrorCode::IncompatibleVersion,
std::format("State version {} is from a newer Core. "
"Please update/restart to load this state.",
dataVersion)});
dataVersion));
} else {
return std::unexpected(Api::Error{
return Api::fail(
Api::ErrorCode::IncompatibleVersion,
std::format("State version {} is too old. "
"Maximum supported age is {} versions.",
dataVersion,
Api::MAX_SUPPORTED_STATE_VERSION_AGE)});
Api::MAX_SUPPORTED_STATE_VERSION_AGE));
}
}
@@ -59,18 +59,18 @@ namespace Echoion::Core
if (dataVersion == CURRENT_VERSION) {
auto parsed = Void::Json::parse(jsonStr);
if (!parsed) {
return std::unexpected(Api::Error{
return Api::fail(
Api::ErrorCode::ParseError,
std::format("Failed to parse state ({}:{}): {}",
parsed.error().line, parsed.error().col,
parsed.error().message)});
parsed.error().message));
}
auto state = Void::Json::from_json<StateV1>(*parsed);
if (!state) {
return std::unexpected(Api::Error{
return Api::fail(
Api::ErrorCode::ParseError,
std::format("Failed to decode state: field '{}': {}",
state.error().field, state.error().message)});
state.error().field, state.error().message));
}
return *state;
}