From e2aa04fdef84652492f7cd11ce9f4d971dd7a3c3 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 3 Oct 2018 09:31:02 -0400 Subject: Win32Fatal: support a "hint" for the error The callsite might have extra context which is helpful for interpreting the error message. --- src/util.cc | 8 ++++++-- src/util.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/util.cc b/src/util.cc index 760bc23..8e67fd9 100644 --- a/src/util.cc +++ b/src/util.cc @@ -432,8 +432,12 @@ string GetLastErrorString() { return msg; } -void Win32Fatal(const char* function) { - Fatal("%s: %s", function, GetLastErrorString().c_str()); +void Win32Fatal(const char* function, const char* hint) { + if (hint) { + Fatal("%s: %s (%s)", function, GetLastErrorString().c_str(), hint); + } else { + Fatal("%s: %s", function, GetLastErrorString().c_str()); + } } #endif diff --git a/src/util.h b/src/util.h index 1b4227c..6a4a7a9 100644 --- a/src/util.h +++ b/src/util.h @@ -119,7 +119,7 @@ bool Truncate(const string& path, size_t size, string* err); string GetLastErrorString(); /// Calls Fatal() with a function name and GetLastErrorString. -NORETURN void Win32Fatal(const char* function); +NORETURN void Win32Fatal(const char* function, const char* hint = NULL); #endif #endif // NINJA_UTIL_H_ -- cgit v1.2.1