summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2018-10-03 13:31:02 (GMT)
committerBen Boeckel <mathstuf@gmail.com>2018-11-09 15:51:17 (GMT)
commite2aa04fdef84652492f7cd11ce9f4d971dd7a3c3 (patch)
tree68124996c851014fc430b14ee7f7ccac6055422b
parent6a9411e784c58492e62a5dcb7d5d1aadfb2e1830 (diff)
downloadNinja-e2aa04fdef84652492f7cd11ce9f4d971dd7a3c3.zip
Ninja-e2aa04fdef84652492f7cd11ce9f4d971dd7a3c3.tar.gz
Ninja-e2aa04fdef84652492f7cd11ce9f4d971dd7a3c3.tar.bz2
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.cc8
-rw-r--r--src/util.h2
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_