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

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 4770)
+++ runtime/vm/parser.cc (working copy)
@@ -3310,7 +3310,9 @@
Api::NewLocalHandle(url),
Api::NewLocalHandle(import_map));
if (Dart_IsError(result)) {
- ErrorMsg(token_pos, "library handler failed: %s", Dart_GetError(result));
+ Error& prev_error = Error::Handle();
+ prev_error ^= Api::UnwrapHandle(result);
+ AppendErrorMsg(prev_error, token_pos, "library handler failed");
}
return result;
}
@@ -5254,6 +5256,23 @@
}
+RawError* Parser::FormatErrorWithAppend(const Error& 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.ToErrorCString()));
hausner 2012/03/01 00:10:16 Why not use prev_error.message()? There is still a
srdjan 2012/03/01 00:17:34 There is no Error::message(). Some subclasses impl
turnidge 2012/03/07 00:41:21 You should be able to use ToErrorCString on any re
+ 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 +5373,18 @@
}
+void Parser::AppendErrorMsg(
+ const Error& 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