blob: 2674b889a15340bac6ce4d4e93b9a0f9ccfad4b1 (
plain)
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
|
#include "pch.h"
#include "vcpkg_Checks.h"
#include "vcpkg_System.h"
#include "vcpkglib.h"
namespace vcpkg::Checks
{
[[noreturn]] void unreachable(const LineInfo& line_info)
{
System::println(System::Color::error, "Error: Unreachable code was reached");
System::println(System::Color::error, line_info.to_string()); // Always print line_info here
#ifndef NDEBUG
std::abort();
#else
::exit(EXIT_FAILURE);
#endif
}
[[noreturn]] void exit_with_code(const LineInfo& line_info, const int exit_code)
{
Debug::println(System::Color::error, line_info.to_string());
::exit(exit_code);
}
[[noreturn]] void exit_with_message(const LineInfo& line_info, const CStringView errorMessage)
{
System::println(System::Color::error, errorMessage);
exit_fail(line_info);
}
void check_exit(const LineInfo& line_info, bool expression)
{
if (!expression)
{
exit_with_message(line_info, "");
}
}
void check_exit(const LineInfo& line_info, bool expression, const CStringView errorMessage)
{
if (!expression)
{
exit_with_message(line_info, errorMessage);
}
}
}
|