Make ValFromJSON return zeek::expected instead of a variant

This commit is contained in:
Tim Wojtulewicz 2025-04-02 14:44:47 -07:00
parent e545fe8256
commit 201d4508e6
6 changed files with 64 additions and 60 deletions

View file

@ -440,10 +440,10 @@ void Redis::HandleGetResult(redisReply* reply, ResultCallback* callback) {
res = ParseReplyError("get", reply->str);
else {
auto val = zeek::detail::ValFromJSON(reply->str, val_type, Func::nil);
if ( std::holds_alternative<ValPtr>(val) )
res = {ReturnCode::SUCCESS, "", std::get<ValPtr>(val)};
if ( val )
res = {ReturnCode::SUCCESS, "", val.value()};
else
res = {ReturnCode::OPERATION_FAILED, std::get<std::string>(val)};
res = {ReturnCode::OPERATION_FAILED, val.error()};
}
freeReplyObject(reply);