summaryrefslogtreecommitdiffstats
path: root/library/cpp/yt/system/env-inl.h
blob: 22fbab469228ff6b0c4d979583b7b7bf4cf78e74 (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
#ifndef ENV_INL_H_
#error "Direct inclusion of this file is not allowed, include env.h"
// For the sake of sane code completion.
#include "env.h"
#endif

#include <util/string/cast.h>

namespace NYT {

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

namespace NDetail {

[[noreturn]] void ThrowFailedToParseEnvValueError(TStringBuf name, TStringBuf value);

} // namespace NDetail

template <class T>
T GetEnvValueOrThrow(TStringBuf name)
{
    auto value = GetEnvValueOrThrow(name);
    T result;
    if (!TryFromString<T>(value, result)) {
        NDetail::ThrowFailedToParseEnvValueError(name, value);
    }
    return result;
}

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

} // namespace NYT