![]() |
Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
|
#include "nix/util/error.hh"#include <boost/outcome/result.hpp>#include <functional>#include <type_traits>Go to the source code of this file.
Macros | |
| #define | NIX_THROW_NATIVE_SYS_ERROR_HANDLER(...) |
Typedefs | |
| template<typename T, typename E> | |
| using | nix::Result = outcome::unchecked<T, E> |
Functions | |
| template<typename T, typename E, typename F> | |
| T | nix::valueOr (Result< T, E > &&result, F &&f) |
| #define NIX_THROW_NATIVE_SYS_ERROR_HANDLER | ( | ... | ) |
A handler for nix::valueOr that throws a NativeSysError from the error, with the given format string and arguments.
Example:
auto fd = valueOr(openFileReadonly(path), NIX_THROW_NATIVE_SYS_ERROR_HANDLER("opening file %s", PathFmt(path)));
| using nix::Result = outcome::unchecked<T, E> |
Either a T or an error E, for functions whose failures are expected and should be checked by the caller rather than thrown.
| T nix::valueOr | ( | Result< T, E > && | result, |
| F && | f ) |
The value of result, or else what f returns given its error.
Usually f throws instead, e.g. a NativeSysError built from the error with some context, in which case it need not return anything.