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

Unified Diff: runtime/vm/object.cc

Issue 9148048: Standardize error printing a bit by moving it to the Error object and (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 11 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/object.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
===================================================================
--- runtime/vm/object.cc (revision 3218)
+++ runtime/vm/object.cc (working copy)
@@ -15,6 +15,7 @@
#include "vm/compiler_stats.h"
#include "vm/class_finalizer.h"
#include "vm/dart.h"
+#include "vm/dart_entry.h"
#include "vm/debuginfo.h"
#include "vm/exceptions.h"
#include "vm/growable_array.h"
@@ -5036,6 +5037,12 @@
}
+const char* Error::ToErrorCString() const {
+ UNREACHABLE();
+ return "Internal Error";
+}
+
+
const char* Error::ToCString() const {
// Error is an abstract class. We should never reach here.
UNREACHABLE();
@@ -5063,6 +5070,12 @@
}
+const char* ApiError::ToErrorCString() const {
+ const String& msg_str = String::Handle(message());
+ return msg_str.ToCString();
+}
+
+
const char* ApiError::ToCString() const {
return "ApiError";
}
@@ -5088,6 +5101,12 @@
}
+const char* LanguageError::ToErrorCString() const {
+ const String& msg_str = String::Handle(message());
+ return msg_str.ToCString();
+}
+
+
const char* LanguageError::ToCString() const {
return "LanguageError";
}
@@ -5121,6 +5140,36 @@
}
+const char* UnhandledException::ToErrorCString() const {
+ Isolate* isolate = Isolate::Current();
+ HANDLESCOPE(isolate);
+ Object& strtmp = Object::Handle();
+
+ const Instance& exc = Instance::Handle(exception());
+ strtmp = DartLibraryCalls::ToString(exc);
+ const char* exc_str =
+ "<Received error while converting exception to string>";
+ if (!strtmp.IsError()) {
+ exc_str = strtmp.ToCString();
+ }
+ const Instance& stack = Instance::Handle(stacktrace());
+ strtmp = DartLibraryCalls::ToString(stack);
+ const char* stack_str =
+ "<Received error while converting stack trace to string>";
+ if (!strtmp.IsError()) {
+ stack_str = strtmp.ToCString();
+ }
+
+ const char* format = "Unhandled exception:\n%s\n%s";
+ int len = (strlen(exc_str) + strlen(stack_str) + strlen(format)
+ - 4 // Two '%s'
+ + 1); // '\0'
+ char* chars = reinterpret_cast<char*>(isolate->current_zone()->Allocate(len));
+ OS::SNPrint(chars, len, format, exc_str, stack_str);
+ return chars;
+}
+
+
const char* UnhandledException::ToCString() const {
return "UnhandledException";
}
@@ -5146,6 +5195,12 @@
}
+const char* UnwindError::ToErrorCString() const {
+ UNIMPLEMENTED();
+ return "UnwindError";
+}
+
+
const char* UnwindError::ToCString() const {
return "UnwindError";
}
« no previous file with comments | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698