diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2018-10-03 09:31:02 -0400 |
---|---|---|
committer | Ben Boeckel <mathstuf@gmail.com> | 2018-11-09 10:51:17 -0500 |
commit | e2aa04fdef84652492f7cd11ce9f4d971dd7a3c3 (patch) | |
tree | 68124996c851014fc430b14ee7f7ccac6055422b | |
parent | 6a9411e784c58492e62a5dcb7d5d1aadfb2e1830 (diff) | |
download | ninja-e2aa04fdef84652492f7cd11ce9f4d971dd7a3c3.tar.gz |
Win32Fatal: support a "hint" for the error
The callsite might have extra context which is helpful for interpreting
the error message.
-rw-r--r-- | src/util.cc | 8 | ||||
-rw-r--r-- | 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 @@ -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_ |