[vm] Elaborate on DartDev missing error.

This change refactors CreateAndSetupDartDevIsolate slightly to
exit as soon as we know we cannot resolve DartDev.
Expands on the error message to be a bit more informative about
what went wrong.

Before:
  Failed to start the Dart CLI isolate
  (null).
  Observatory server failed to start after 1 tries
  [...]

After:
  Failed to start the Dart CLI isolate. Could not resolve DartDev snapshot or kernel.
  [...]

TEST=CQ

Change-Id: Iad3302dc4e64eef06b97c8b76a82b04c97a7089e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/220546
Commit-Queue: Clement Skau <cskau@google.com>
Reviewed-by: Ben Konyi <bkonyi@google.com>
diff --git a/runtime/bin/main.cc b/runtime/bin/main.cc
index 37f1772..88e7c9e9 100644
--- a/runtime/bin/main.cc
+++ b/runtime/bin/main.cc
@@ -637,36 +637,36 @@
       delete app_snapshot;
     }
 
-    if (dartdev_path.get() != nullptr) {
-      isolate_group_data =
-          new IsolateGroupData(DART_DEV_ISOLATE_NAME, packages_config, nullptr,
-                               isolate_run_app_snapshot);
-      uint8_t* application_kernel_buffer = NULL;
-      intptr_t application_kernel_buffer_size = 0;
-      dfe.ReadScript(dartdev_path.get(), &application_kernel_buffer,
-                     &application_kernel_buffer_size, /*decode_uri=*/false);
-      isolate_group_data->SetKernelBufferNewlyOwned(
-          application_kernel_buffer, application_kernel_buffer_size);
-
-      isolate_data = new IsolateData(isolate_group_data);
-      isolate = Dart_CreateIsolateGroup(
-          DART_DEV_ISOLATE_NAME, DART_DEV_ISOLATE_NAME, isolate_snapshot_data,
-          isolate_snapshot_instructions, flags, isolate_group_data,
-          isolate_data, error);
+    if (dartdev_path.get() == nullptr) {
+      Syslog::PrintErr(
+          "Failed to start the Dart CLI isolate. Could not resolve DartDev "
+          "snapshot or kernel.\n");
+      delete isolate_data;
+      delete isolate_group_data;
+      return nullptr;
     }
+
+    isolate_group_data =
+        new IsolateGroupData(DART_DEV_ISOLATE_NAME, packages_config, nullptr,
+                             isolate_run_app_snapshot);
+    uint8_t* application_kernel_buffer = NULL;
+    intptr_t application_kernel_buffer_size = 0;
+    dfe.ReadScript(dartdev_path.get(), &application_kernel_buffer,
+                   &application_kernel_buffer_size, /*decode_uri=*/false);
+    isolate_group_data->SetKernelBufferNewlyOwned(
+        application_kernel_buffer, application_kernel_buffer_size);
+
+    isolate_data = new IsolateData(isolate_group_data);
+    isolate = Dart_CreateIsolateGroup(
+        DART_DEV_ISOLATE_NAME, DART_DEV_ISOLATE_NAME, isolate_snapshot_data,
+        isolate_snapshot_instructions, flags, isolate_group_data, isolate_data,
+        error);
   }
 
-  Dart_Isolate created_isolate = nullptr;
-  if (isolate == nullptr) {
-    Syslog::PrintErr("Failed to start the Dart CLI isolate\n");
-    delete isolate_data;
-    delete isolate_group_data;
-    return nullptr;
-  } else {
-    created_isolate = IsolateSetupHelper(
-        isolate, false, DART_DEV_ISOLATE_NAME, packages_config,
-        isolate_run_app_snapshot, flags, error, exit_code);
-  }
+  Dart_Isolate created_isolate =
+      IsolateSetupHelper(isolate, false, DART_DEV_ISOLATE_NAME, packages_config,
+                         isolate_run_app_snapshot, flags, error, exit_code);
+
   int64_t end = Dart_TimelineGetMicros();
   Dart_TimelineEvent("CreateAndSetupDartDevIsolate", start, end,
                      Dart_Timeline_Event_Duration, 0, NULL, NULL);