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

Side by Side Diff: runtime/bin/main.cc

Issue 8383037: Improve error handling in the process library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/gen_snapshot.cc ('k') | runtime/bin/process.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <assert.h>
6 #include <stdlib.h> 5 #include <stdlib.h>
7 #include <string.h> 6 #include <string.h>
8 #include <stdio.h> 7 #include <stdio.h>
9 8
10 #include "include/dart_api.h" 9 #include "include/dart_api.h"
11 10
12 #include "bin/builtin.h" 11 #include "bin/builtin.h"
13 #include "bin/file.h" 12 #include "bin/file.h"
14 #include "bin/globals.h" 13 #include "bin/globals.h"
15 #include "bin/process_script.h" 14 #include "bin/process_script.h"
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 Dart_NewString("main"), 221 Dart_NewString("main"),
223 0, 222 0,
224 NULL); 223 NULL);
225 224
226 if (Dart_IsValidResult(result)) { 225 if (Dart_IsValidResult(result)) {
227 Dart_Handle result_obj = Dart_GetResult(result); 226 Dart_Handle result_obj = Dart_GetResult(result);
228 if (Dart_ExceptionOccurred(result_obj)) { 227 if (Dart_ExceptionOccurred(result_obj)) {
229 // Print the exception object. 228 // Print the exception object.
230 fprintf(stderr, "An unhandled exception has been thrown\n"); 229 fprintf(stderr, "An unhandled exception has been thrown\n");
231 Dart_Result exception_result = Dart_GetException(result_obj); 230 Dart_Result exception_result = Dart_GetException(result_obj);
232 assert(Dart_IsValidResult(exception_result)); 231 ASSERT(Dart_IsValidResult(exception_result));
233 PrintObject(stderr, Dart_GetResult(exception_result)); 232 PrintObject(stderr, Dart_GetResult(exception_result));
234 // Print the stack trace. 233 // Print the stack trace.
235 Dart_Result stacktrace = Dart_GetStacktrace(result_obj); 234 Dart_Result stacktrace = Dart_GetStacktrace(result_obj);
236 assert(Dart_IsValidResult(stacktrace)); 235 ASSERT(Dart_IsValidResult(stacktrace));
237 PrintObject(stderr, Dart_GetResult(stacktrace)); 236 PrintObject(stderr, Dart_GetResult(stacktrace));
238 fprintf(stderr, "\n"); 237 fprintf(stderr, "\n");
239 Dart_ExitScope(); 238 Dart_ExitScope();
240 Dart_ShutdownIsolate(); 239 Dart_ShutdownIsolate();
241 return 255; // We had an unhandled exception, hence indicate an error. 240 return 255; // We had an unhandled exception, hence indicate an error.
242 } 241 }
243 } else { 242 } else {
244 fprintf(stderr, "%s\n", Dart_GetErrorCString(result)); 243 fprintf(stderr, "%s\n", Dart_GetErrorCString(result));
245 Dart_ExitScope(); 244 Dart_ExitScope();
246 Dart_ShutdownIsolate(); 245 Dart_ShutdownIsolate();
247 return 255; // Indicates we encountered an error. 246 return 255; // Indicates we encountered an error.
248 } 247 }
249 // Keep handling messages until the last active receive port is closed. 248 // Keep handling messages until the last active receive port is closed.
250 result = Dart_RunLoop(); 249 result = Dart_RunLoop();
251 if (!Dart_IsValidResult(result)) { 250 if (!Dart_IsValidResult(result)) {
252 fprintf(stderr, "%s\n", Dart_GetErrorCString(result)); 251 fprintf(stderr, "%s\n", Dart_GetErrorCString(result));
253 Dart_ExitScope(); 252 Dart_ExitScope();
254 Dart_ShutdownIsolate(); 253 Dart_ShutdownIsolate();
255 return 255; // Indicates we encountered an error. 254 return 255; // Indicates we encountered an error.
256 } 255 }
257 Dart_ExitScope(); 256 Dart_ExitScope();
258 // Dump symbol information for the profiler. 257 // Dump symbol information for the profiler.
259 DumpPprofSymbolInfo(); 258 DumpPprofSymbolInfo();
260 // Shutdown the isolate. 259 // Shutdown the isolate.
261 Dart_ShutdownIsolate(); 260 Dart_ShutdownIsolate();
262 return 0; 261 return 0;
263 } 262 }
OLDNEW
« no previous file with comments | « runtime/bin/gen_snapshot.cc ('k') | runtime/bin/process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698