in include/wil/result.h [615:656]
bool GetLastError(_Inout_ wil::FailureInfo& info, unsigned int minSequenceId, HRESULT matchRequirement)
{
if (!errors)
{
return false;
}
// If the last error we saw doesn't meet the filter requirement or if the last error was never
// set, then we couldn't return a result at all...
auto& lastFailure = errors[errorCurrentIndex];
if (minSequenceId >= lastFailure.sequenceId)
{
return false;
}
// With no result filter, we just go to the last error and report it
if (matchRequirement == S_OK)
{
lastFailure.Get(info);
return true;
}
// Find the oldest result matching matchRequirement and passing minSequenceId
ThreadLocalFailureInfo* find = nullptr;
for (auto& error : make_range(errors, errorAllocCount))
{
if ((error.hr == matchRequirement) && (error.sequenceId > minSequenceId))
{
if (!find || (error.sequenceId < find->sequenceId))
{
find = &error;
}
}
}
if (find)
{
find->Get(info);
return true;
}
return false;
}