if (auto FileOrErr = openFormattedFile(Path)) {
// On success, grab a reference to the file and continue.
auto &File = *FileOrErr;
- // ...
+ ...
} else
// On error, extract the Error value and return it.
return FileOrErr.takeError();
return Err;
// On success, grab a reference to the file and continue.
auto &File = *FileOrErr;
- // ...
+ ...
}
This second form is often more readable for functions that involve multiple
return Err;
}
auto &Child = *ChildOrErr;
- // do work
+ // Use Child
+ ...
}
return Error::success();
}
else
return Err;
auto &Child = *ChildOrErr;
- // do work
+ // Use Child
+ ...
}
return DeferredErrs;
}
Error Err;
for (auto &Child : Ar->children(Err)) {
- // Use Child - we only enter the loop when it’s valid.
+ // Use Child - we only enter the loop when it’s valid
+ ...
}
// Check Err after the loop to ensure it didn’t break due to an error.
if (Err)