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

Unified Diff: runtime/bin/main.cc

Issue 8501034: Deal with unhandled exceptions the same way in all Dart api functions. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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/bin/gen_snapshot.cc ('k') | runtime/bin/process.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/main.cc
===================================================================
--- runtime/bin/main.cc (revision 1469)
+++ runtime/bin/main.cc (working copy)
@@ -98,38 +98,38 @@
static Dart_Handle SetupRuntimeOptions(CommandLineOptions* options) {
int options_count = options->count();
Dart_Handle dart_arguments = Dart_NewList(options_count);
- if (!Dart_IsValid(dart_arguments)) {
+ if (Dart_IsError(dart_arguments)) {
return dart_arguments;
}
for (int i = 0; i < options_count; i++) {
Dart_Handle argument_value = Dart_NewString(options->GetArgument(i));
- if (!Dart_IsValid(argument_value)) {
+ if (Dart_IsError(argument_value)) {
return argument_value;
}
Dart_Handle result = Dart_ListSetAt(dart_arguments, i, argument_value);
- if (!Dart_IsValid(result)) {
+ if (Dart_IsError(result)) {
return result;
}
}
Dart_Handle core_lib_url = Dart_NewString("dart:coreimpl");
- if (!Dart_IsValid(core_lib_url)) {
+ if (Dart_IsError(core_lib_url)) {
return core_lib_url;
}
Dart_Handle core_lib = Dart_LookupLibrary(core_lib_url);
- if (!Dart_IsValid(core_lib)) {
+ if (Dart_IsError(core_lib)) {
return core_lib;
}
Dart_Handle runtime_options_class_name = Dart_NewString("RuntimeOptions");
- if (!Dart_IsValid(runtime_options_class_name)) {
+ if (Dart_IsError(runtime_options_class_name)) {
return runtime_options_class_name;
}
Dart_Handle runtime_options_class = Dart_GetClass(
core_lib, runtime_options_class_name);
- if (!Dart_IsValid(runtime_options_class)) {
+ if (Dart_IsError(runtime_options_class)) {
return runtime_options_class;
}
Dart_Handle native_name = Dart_NewString("_nativeArguments");
- if (!Dart_IsValid(native_name)) {
+ if (Dart_IsError(native_name)) {
return native_name;
}
@@ -164,7 +164,7 @@
// Load the specified script.
library = LoadScript(script_name);
- if (!Dart_IsValid(library)) {
+ if (Dart_IsError(library)) {
const char* err_msg = Dart_GetError(library);
fprintf(stderr, "Errors encountered while loading script: %s\n", err_msg);
Dart_ExitScope();
@@ -203,16 +203,6 @@
}
-static void PrintObject(FILE* out, Dart_Handle object) {
- Dart_Handle result = Dart_ToString(object);
- if (Dart_IsValid(result)) {
- PrintString(out, result);
- } else {
- fprintf(out, "%s\n", Dart_GetError(result));
- }
-}
-
-
int main(int argc, char** argv) {
char* script_name;
CommandLineOptions vm_options(argc);
@@ -250,7 +240,7 @@
Dart_EnterScope();
if (HasCompileAll(vm_options)) {
Dart_Handle result = Dart_CompileAll();
- if (!Dart_IsValid(result)) {
+ if (Dart_IsError(result)) {
fprintf(stderr, "%s\n", Dart_GetError(result));
Dart_ExitScope();
Dart_ShutdownIsolate();
@@ -261,7 +251,7 @@
// Create a dart options object that can be accessed from dart code.
Dart_Handle options_result = SetupRuntimeOptions(&dart_options);
- if (!Dart_IsValid(options_result)) {
+ if (Dart_IsError(options_result)) {
fprintf(stderr, "%s\n", Dart_GetError(options_result));
Dart_ExitScope();
Dart_ShutdownIsolate();
@@ -272,7 +262,7 @@
// Lookup and invoke the top level main function.
Dart_Handle script_url = Dart_NewString(canonical_script_name);
Dart_Handle library = Dart_LookupLibrary(script_url);
- if (!Dart_IsValid(library)) {
+ if (Dart_IsError(library)) {
fprintf(stderr, "%s\n", Dart_GetError(library));
Dart_ExitScope();
Dart_ShutdownIsolate();
@@ -284,24 +274,7 @@
Dart_NewString("main"),
0,
NULL);
- if (Dart_IsValid(result)) {
- if (Dart_ExceptionOccurred(result)) {
- // Print the exception object.
- fprintf(stderr, "An unhandled exception has been thrown\n");
- Dart_Handle exception_result = Dart_GetException(result);
- ASSERT(Dart_IsValid(exception_result));
- PrintObject(stderr, exception_result);
- // Print the stack trace.
- Dart_Handle stacktrace = Dart_GetStacktrace(result);
- ASSERT(Dart_IsValid(stacktrace));
- PrintObject(stderr, stacktrace);
- fprintf(stderr, "\n");
- Dart_ExitScope();
- Dart_ShutdownIsolate();
- free(canonical_script_name);
- return 255; // We had an unhandled exception, hence indicate an error.
- }
- } else {
+ if (Dart_IsError(result)) {
fprintf(stderr, "%s\n", Dart_GetError(result));
Dart_ExitScope();
Dart_ShutdownIsolate();
@@ -310,7 +283,7 @@
}
// Keep handling messages until the last active receive port is closed.
result = Dart_RunLoop();
- if (!Dart_IsValid(result)) {
+ if (Dart_IsError(result)) {
fprintf(stderr, "%s\n", Dart_GetError(result));
Dart_ExitScope();
Dart_ShutdownIsolate();
« 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