Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Unified Diff: tools/gn/input_file_manager.cc

Issue 645253002: GN: Store parse error messages (so they aren't dropped due to races) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« tools/gn/input_file_manager.h ('K') | « tools/gn/input_file_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/gn/input_file_manager.cc
diff --git a/tools/gn/input_file_manager.cc b/tools/gn/input_file_manager.cc
index 0b6159c92a507e601800fa472f1db88ae76ad6b9..3ac1d272797fb80427d634b8def573652966e5c9 100644
--- a/tools/gn/input_file_manager.cc
+++ b/tools/gn/input_file_manager.cc
@@ -215,19 +215,12 @@ const ParseNode* InputFileManager::SyncLoadFile(
}
}
- // The other load could have failed. In this case that error was probably
- // printed to the console, but we need to return something here, so make up a
- // dummy error.
- //
- // There is a race condition. The other load could have failed, but if the
- // other thread is delayed for some reason, this thread could end up
- // reporting the error to the scheduler first (since first error report
- // wins). The user will see this one and the "real" one will be discarded.
+ // The other load could have failed. It is possible that this thread's error
+ // will be reported to the scheduler before the other thread's (and the first
+ // error reported "wins"). Forward the parse error from the other load for
+ // this thread so that the error message is useful.
if (!data->parsed_root) {
brettw 2014/10/14 17:13:09 Remove {}
cjhopman 2014/10/16 18:26:02 Done.
- *err = Err(origin, "File parse failed.",
- "If you see this, I'm really sorry, but a race condition has caused\n"
- "me to eat your error message. It was crunchy. If the parse error\n"
- "in your imported file isn't obvious, try re-running GN.");
+ *err = *data->parse_error;
}
return data->parsed_root.get();
}
@@ -296,6 +289,8 @@ bool InputFileManager::LoadFile(const LocationRange& origin,
if (success) {
data->tokens.swap(tokens);
data->parsed_root = root.Pass();
+ } else {
+ data->parse_error.reset(new Err(*err));
}
// Unblock waiters on this event.
« tools/gn/input_file_manager.h ('K') | « tools/gn/input_file_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698