cemu-vcpkg/toolsrc/src/vcpkg_Checks.cpp

54 lines
1.3 KiB
C++
Raw Normal View History

2017-01-27 12:49:09 -08:00
#include "pch.h"
2016-09-18 20:50:08 -07:00
#include "vcpkg_Checks.h"
#include "vcpkg_System.h"
#include "vcpkglib.h"
2016-09-18 20:50:08 -07:00
2017-01-05 12:47:08 -08:00
namespace vcpkg::Checks
2016-09-18 20:50:08 -07:00
{
[[noreturn]]
void unreachable(const LineInfo& line_info)
2016-09-18 20:50:08 -07:00
{
2017-04-03 16:31:00 -07:00
System::println(System::Color::error, "Error: Unreachable code was reached");
System::println(System::Color::error, line_info.toString()); // Always print line_info here
#ifndef NDEBUG
std::abort();
2016-11-15 17:54:44 -08:00
#else
2017-03-22 17:43:49 -07:00
::exit(EXIT_FAILURE);
2016-11-15 17:54:44 -08:00
#endif
2016-09-18 20:50:08 -07:00
}
[[noreturn]]
void exit_with_code(const LineInfo& line_info, const int exit_code)
{
2017-03-31 17:15:35 -07:00
if (g_debugging)
{
2017-04-03 16:31:00 -07:00
System::println(System::Color::error, line_info.toString());
2017-03-31 17:15:35 -07:00
}
2017-03-22 17:43:49 -07:00
::exit(exit_code);
}
[[noreturn]]
2017-04-03 14:21:51 -07:00
void exit_with_message(const LineInfo& line_info, const CStringView errorMessage)
2016-09-18 20:50:08 -07:00
{
2017-04-03 16:31:00 -07:00
System::println(System::Color::error, errorMessage);
2017-03-22 17:34:17 -07:00
exit_fail(line_info);
2016-09-18 20:50:08 -07:00
}
void check_exit(const LineInfo& line_info, bool expression)
{
if (!expression)
{
exit_with_message(line_info, "");
}
}
2017-04-03 14:21:51 -07:00
void check_exit(const LineInfo& line_info, bool expression, const CStringView errorMessage)
2016-09-18 20:50:08 -07:00
{
if (!expression)
{
exit_with_message(line_info, errorMessage);
2016-09-18 20:50:08 -07:00
}
}
2017-01-05 12:47:08 -08:00
}