2016-09-19 11:50:08 +08:00
|
|
|
#include "vcpkg_Checks.h"
|
|
|
|
|
|
|
|
#include <stdexcept>
|
|
|
|
#include "vcpkg_System.h"
|
|
|
|
|
|
|
|
namespace vcpkg {namespace Checks
|
|
|
|
{
|
|
|
|
void unreachable()
|
|
|
|
{
|
|
|
|
System::println(System::color::error, "Error: Unreachable code was reached");
|
2016-11-05 16:02:15 +08:00
|
|
|
#ifndef NDEBUG
|
|
|
|
std::abort();
|
|
|
|
#endif
|
2016-09-19 11:50:08 +08:00
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void exit_with_message(const char* errorMessage)
|
|
|
|
{
|
|
|
|
System::println(System::color::error, errorMessage);
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void throw_with_message(const char* errorMessage)
|
|
|
|
{
|
|
|
|
throw std::runtime_error(errorMessage);
|
|
|
|
}
|
|
|
|
|
|
|
|
void check_throw(bool expression, const char* errorMessage)
|
|
|
|
{
|
|
|
|
if (!expression)
|
|
|
|
{
|
|
|
|
throw_with_message(errorMessage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void check_exit(bool expression, const char* errorMessage)
|
|
|
|
{
|
|
|
|
if (!expression)
|
|
|
|
{
|
2016-09-30 05:31:28 +08:00
|
|
|
exit_with_message(errorMessage);
|
2016-09-19 11:50:08 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}}
|