Chromium Code Reviews| Index: runtime/bin/main.cc |
| =================================================================== |
| --- runtime/bin/main.cc (revision 25027) |
| +++ runtime/bin/main.cc (working copy) |
| @@ -593,10 +593,11 @@ |
| } |
| +static const int kCompilationErrorExitCode = 254; // Indicates a compile error. |
| static const int kErrorExitCode = 255; // Indicates we encountered an error. |
|
siva
2013/07/15 22:42:20
Should we change the comment of this to state
// I
regis
2013/07/15 23:32:47
Done.
|
| -static int ErrorExit(const char* format, ...) { |
| +static int ErrorExit(int exit_code, const char* format, ...) { |
| va_list arguments; |
| va_start(arguments, format); |
| Log::VPrintErr(format, arguments); |
| @@ -606,10 +607,17 @@ |
| Dart_ExitScope(); |
| Dart_ShutdownIsolate(); |
| - return kErrorExitCode; |
| + return exit_code; |
| } |
| +static int DartErrorExit(Dart_Handle error) { |
| + const int exit_code = Dart_IsCompilationError(error) ? |
| + kCompilationErrorExitCode: kErrorExitCode; |
|
siva
2013/07/15 22:42:20
kCompilationErrorExitCode : kErrorExitCode
regis
2013/07/15 23:32:47
Done.
|
| + return ErrorExit(exit_code, "%s\n", Dart_GetError(error)); |
| +} |
| + |
| + |
| static void ShutdownIsolate(void* callback_data) { |
| IsolateData* isolate_data = reinterpret_cast<IsolateData*>(callback_data); |
| EventHandler* handler = isolate_data->event_handler; |
| @@ -767,14 +775,14 @@ |
| if (has_compile_all) { |
| result = Dart_CompileAll(); |
| if (Dart_IsError(result)) { |
| - return ErrorExit("%s\n", Dart_GetError(result)); |
| + return DartErrorExit(result); |
| } |
| } |
| if (has_check_function_fingerprints) { |
| result = Dart_CheckFunctionFingerprints(); |
| if (Dart_IsError(result)) { |
| - return ErrorExit("%s\n", Dart_GetError(result)); |
| + return DartErrorExit(result); |
| } |
| } |
| @@ -782,19 +790,21 @@ |
| Dart_Handle options_result = |
| SetupRuntimeOptions(&dart_options, executable_name, script_name); |
| if (Dart_IsError(options_result)) { |
| - return ErrorExit("%s\n", Dart_GetError(options_result)); |
| + return DartErrorExit(options_result); |
| } |
| // Lookup the library of the root script. |
| Dart_Handle library = Dart_RootLibrary(); |
| if (Dart_IsNull(library)) { |
| - return ErrorExit("Unable to find root library for '%s'\n", |
| + return ErrorExit(kErrorExitCode, |
| + "Unable to find root library for '%s'\n", |
| script_name); |
| } |
| // Set debug breakpoint if specified on the command line. |
| if (breakpoint_at != NULL) { |
| result = SetBreakpoint(breakpoint_at, library); |
| if (Dart_IsError(result)) { |
| - return ErrorExit("Error setting breakpoint at '%s': %s\n", |
| + return ErrorExit(kErrorExitCode, |
| + "Error setting breakpoint at '%s': %s\n", |
| breakpoint_at, |
| Dart_GetError(result)); |
| } |
| @@ -802,19 +812,19 @@ |
| if (has_print_script) { |
| result = GenerateScriptSource(); |
| if (Dart_IsError(result)) { |
| - return ErrorExit("%s\n", Dart_GetError(result)); |
| + return DartErrorExit(result); |
| } |
| } else { |
| // Lookup and invoke the top level main function. |
| result = Dart_Invoke(library, DartUtils::NewString("main"), 0, NULL); |
| if (Dart_IsError(result)) { |
| - return ErrorExit("%s\n", Dart_GetError(result)); |
| + return DartErrorExit(result); |
| } |
| // Keep handling messages until the last active receive port is closed. |
| result = Dart_RunLoop(); |
| if (Dart_IsError(result)) { |
| - return ErrorExit("%s\n", Dart_GetError(result)); |
| + return DartErrorExit(result); |
| } |
| } |
| } |