| Index: runtime/vm/object.cc
|
| ===================================================================
|
| --- runtime/vm/object.cc (revision 44523)
|
| +++ runtime/vm/object.cc (working copy)
|
| @@ -13469,20 +13469,21 @@
|
|
|
| const char* UnhandledException::ToErrorCString() const {
|
| Isolate* isolate = Isolate::Current();
|
| - if (exception() == isolate->object_store()->out_of_memory()) {
|
| - return "Unhandled exception:\nOut of memory";
|
| - }
|
| - if (exception() == isolate->object_store()->stack_overflow()) {
|
| - return "Unhandled exception:\nStack overflow";
|
| - }
|
| 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 char* exc_str;
|
| + if (exception() == isolate->object_store()->out_of_memory()) {
|
| + exc_str = "Out of Memory";
|
| + } else if (exception() == isolate->object_store()->stack_overflow()) {
|
| + exc_str = "Stack Overflow";
|
| + } else {
|
| + const Instance& exc = Instance::Handle(exception());
|
| + strtmp = DartLibraryCalls::ToString(exc);
|
| + if (!strtmp.IsError()) {
|
| + exc_str = strtmp.ToCString();
|
| + } else {
|
| + exc_str = "<Received error while converting exception to string>";
|
| + }
|
| }
|
| const Instance& stack = Instance::Handle(stacktrace());
|
| strtmp = DartLibraryCalls::ToString(stack);
|
| @@ -13491,11 +13492,8 @@
|
| 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'
|
| + intptr_t len = OS::SNPrint(NULL, 0, format, exc_str, stack_str);
|
| char* chars = isolate->current_zone()->Alloc<char>(len);
|
| OS::SNPrint(chars, len, format, exc_str, stack_str);
|
| return chars;
|
|
|