diff options
Diffstat (limited to 'third_party/nix/src/libutil/status.hh')
-rw-r--r-- | third_party/nix/src/libutil/status.hh | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/third_party/nix/src/libutil/status.hh b/third_party/nix/src/libutil/status.hh new file mode 100644 index 000000000000..aeee0f502257 --- /dev/null +++ b/third_party/nix/src/libutil/status.hh @@ -0,0 +1,17 @@ +#pragma once + +#include <absl/status/status.h> +#include <absl/strings/str_format.h> +#include <absl/strings/string_view.h> + +#include "libutil/types.hh" + +namespace nix::util { + +inline void OkOrThrow(absl::Status status) { + if (!status.ok()) { + throw Error(absl::StrFormat("Operation failed: %s", status.ToString())); + } +} + +} // namespace nix::util |