diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2016-09-18 20:50:08 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2016-09-18 20:54:03 -0700 |
| commit | ccca198c1b1730b0241911cb56dc8e3504958b2a (patch) | |
| tree | a2dd9b8b087a09afdcecc5cbb3377bed15127eb2 /toolsrc/src/vcpkg_Checks.cpp | |
| download | vcpkg-ccca198c1b1730b0241911cb56dc8e3504958b2a.tar.gz vcpkg-ccca198c1b1730b0241911cb56dc8e3504958b2a.zip | |
Initial commit
Diffstat (limited to 'toolsrc/src/vcpkg_Checks.cpp')
| -rw-r--r-- | toolsrc/src/vcpkg_Checks.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/toolsrc/src/vcpkg_Checks.cpp b/toolsrc/src/vcpkg_Checks.cpp new file mode 100644 index 000000000..d5433b1f5 --- /dev/null +++ b/toolsrc/src/vcpkg_Checks.cpp @@ -0,0 +1,41 @@ +#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"); + 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) + { + System::println(System::color::error, errorMessage); + exit(EXIT_FAILURE); + } + } +}} |
