aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/system/exit.h
blob: e06c0bd3ddda0a90e533cbb904650d927063e239 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once

#include <library/cpp/yt/misc/enum.h>

#include <type_traits>

namespace NYT {

////////////////////////////////////////////////////////////////////////////////

DEFINE_ENUM(EProcessExitCode,
    ((OK)                  (0))
    ((ArgumentsError)      (1))
    ((GenericError)        (2))
    ((IOError)             (3))
    ((OutOfMemory)         (9))
);

//! Invokes _exit to abort the process immediately without calling any cleanup code
//! and without printing any details to stderr.
[[noreturn]] void AbortProcessSilently(int exitCode);

//! A typed version of #AbortProcessSilently.
template <class E>
    requires std::is_enum_v<E>
[[noreturn]] void AbortProcessSilently(E exitCode);

//! Invokes _exit to abort the process immediately
//! without calling any cleanup code but printing error message to stderr.
[[noreturn]] void AbortProcessDramatically(
    int exitCode,
    TStringBuf exitCodeStr,
    TStringBuf message);

//! A typed version of #AbortProcessDramatically.
template <class E>
    requires std::is_enum_v<E>
[[noreturn]] void AbortProcessDramatically(
    E exitCode,
    TStringBuf message);

////////////////////////////////////////////////////////////////////////////////

} // namespace NYT

#define EXIT_INL_H_
#include "exit-inl.h"
#undef EXIT_INL_H_