You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mesos.apache.org by Benjamin Mahler <bm...@apache.org> on 2018/04/10 21:20:21 UTC
CHECK_NOTNONE / CHECK_NOTERROR
Just an FYI about some recently added CHECKs that make some minor changes
to the way we write code:
(1) CHECK_NOTNONE:
Much like glog's CHECK_NOTNULL, sometimes you know from invariants that an
Option cannot be in the none state and you want to "de-reference" it
without writing logic to handle the none case:
Option<T> func(...);
T t = CHECK_NOTNULL(func(...));
Option<T> some_option = ...;
T t = CHECK_NOTNONE(std::move(some_option));
Our existing code tends to use unguarded .get() calls, so hopefully this
new pattern makes it clearer when we're assuming an option is in the some
case.
(2) CHECK_NOTERROR:
This is the same, but for Try:
Try<T> func(...);
T t = CHECK_NOTERROR(func(...));
Try<T> some_try = ...;
T t = CHECK_NOTERROR(std::move(some_try));
You can find them here:
https://github.com/apache/mesos/blob/88f5629e510d71a32bd7e0ff7ee09e150f944e72/3rdparty/stout/include/stout/check.hpp