exit.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. ((InternalError) (4))
  12. ((OutOfMemory) (9))
  13. );
  14. //! Invokes _exit to abort the process immediately without calling any cleanup code
  15. //! and without printing any details to stderr.
  16. [[noreturn]] void AbortProcessSilently(int exitCode);
  17. //! A typed version of #AbortProcessSilently.
  18. template <class E>
  19. requires std::is_enum_v<E>
  20. [[noreturn]] void AbortProcessSilently(E exitCode);
  21. //! Invokes _exit to abort the process immediately
  22. //! without calling any cleanup code but printing error message to stderr.
  23. [[noreturn]] void AbortProcessDramatically(
  24. int exitCode,
  25. TStringBuf exitCodeStr,
  26. TStringBuf message);
  27. //! A typed version of #AbortProcessDramatically.
  28. template <class E>
  29. requires std::is_enum_v<E>
  30. [[noreturn]] void AbortProcessDramatically(
  31. E exitCode,
  32. TStringBuf message);
  33. ////////////////////////////////////////////////////////////////////////////////
  34. } // namespace NYT
  35. #define EXIT_INL_H_
  36. #include "exit-inl.h"
  37. #undef EXIT_INL_H_