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

Unified Diff: runtime/vm/parser.cc

Issue 9559001: Fix Issue 1846: Improve error reporting in presence of imports. With this CL: (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 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
« no previous file with comments | « runtime/vm/parser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 4760)
+++ runtime/vm/parser.cc (working copy)
@@ -3310,7 +3310,8 @@
Api::NewLocalHandle(url),
Api::NewLocalHandle(import_map));
if (Dart_IsError(result)) {
- ErrorMsg(token_pos, "library handler failed: %s", Dart_GetError(result));
+ AppendErrorMsg(
+ Dart_GetError(result), token_pos, "library handler failed");
hausner 2012/02/29 22:56:02 Dart_GetError() copies the error message out of an
srdjan 2012/02/29 23:47:04 Done.
}
return result;
}
@@ -5254,6 +5255,23 @@
}
+RawError* Parser::FormatErrorWithAppend(const char* prev_error,
+ const Script& script,
+ intptr_t token_index,
+ const char* message_header,
+ const char* format,
+ va_list args) {
+ const intptr_t kMessageBufferSize = 512;
+ char message_buffer[kMessageBufferSize];
+ FormatMessage(script, token_index, message_header,
+ message_buffer, kMessageBufferSize,
+ format, args);
+ const String& msg1 = String::Handle(String::New(prev_error));
+ const String& msg2 = String::Handle(String::New(message_buffer));
+ return LanguageError::New(String::Handle(String::Concat(msg1, msg2)));
+}
+
+
RawError* Parser::FormatError(const Script& script,
intptr_t token_index,
const char* message_header,
@@ -5354,6 +5372,18 @@
}
+void Parser::AppendErrorMsg(
+ const char* prev_error, intptr_t token_index, const char* format, ...) {
+ va_list args;
+ va_start(args, format);
+ const Error& error = Error::Handle(FormatErrorWithAppend(
+ prev_error, script_, token_index, "Error", format, args));
+ va_end(args);
+ Isolate::Current()->long_jump_base()->Jump(1, error);
+ UNREACHABLE();
+}
+
+
void Parser::Warning(intptr_t token_index, const char* format, ...) {
if (FLAG_silent_warnings) return;
va_list args;
« no previous file with comments | « runtime/vm/parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698