exit.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #pragma once
  2. #include <library/cpp/yt/misc/enum.h>
  3. #include <type_traits>
  4. namespace NYT {
  5. ////////////////////////////////////////////////////////////////////////////////
  6. DEFINE_ENUM(EProcessExitCode,
  7. ((OK) (0))
  8. ((ArgumentsError) (1))
  9. ((GenericError) (2))
  10. ((IOError) (3))
  11. ((OutOfMemory) (9))
  12. );
  13. //! Invokes _exit to abort the process immediately without calling any cleanup code
  14. //! and without printing any details to stderr.
  15. [[noreturn]] void AbortProcessSilently(int exitCode);
  16. //! A typed version of #AbortProcessSilently.
  17. template <class E>
  18. requires std::is_enum_v<E>
  19. [[noreturn]] void AbortProcessSilently(E exitCode);
  20. //! Invokes _exit to abort the process immediately
  21. //! without calling any cleanup code but printing error message to stderr.
  22. [[noreturn]] void AbortProcessDramatically(
  23. int exitCode,
  24. TStringBuf exitCodeStr,
  25. TStringBuf message);
  26. //! A typed version of #AbortProcessDramatically.
  27. template <class E>
  28. requires std::is_enum_v<E>
  29. [[noreturn]] void AbortProcessDramatically(
  30. E exitCode,
  31. TStringBuf message);
  32. ////////////////////////////////////////////////////////////////////////////////
  33. } // namespace NYT
  34. #define EXIT_INL_H_
  35. #include "exit-inl.h"
  36. #undef EXIT_INL_H_