cros_sdk: Improve error message outside cros root

When running cros_sdk outside a chromium os root but in a directory
containing .repo or .gclient (e.g. chromium), the current error message
is a strange traceback referring to bad URLs.  Check for the underlying
error case and give a better error message.

BUG=chromium:634317
TEST=Copied patched cros_sdk.py into a chromium checkout and ran there.

Change-Id: Ia1b43ed9f4370a850c7f5ab64c23e6db7eada75d
Reviewed-on: https://chromium-review.googlesource.com/556153
Commit-Ready: Benjamin Gordon <bmgordon@chromium.org>
Tested-by: Benjamin Gordon <bmgordon@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/cros_sdk.py b/scripts/cros_sdk.py
index b8d1f79..84f6137 100644
--- a/scripts/cros_sdk.py
+++ b/scripts/cros_sdk.py
@@ -588,7 +588,7 @@
 
   host = os.uname()[4]
   if host != 'x86_64':
-    parser.error(
+    cros_build_lib.Die(
         "cros_sdk is currently only supported on x86_64; you're running"
         " %s.  Please find a x86_64 machine." % (host,))
 
@@ -596,6 +596,15 @@
   if options.proxy_sim:
     _ReportMissing(osutils.FindMissingBinaries(PROXY_NEEDED_TOOLS))
 
+  if (sdk_latest_version == '<unknown>' or
+      bootstrap_latest_version == '<unknown>'):
+    cros_build_lib.Die(
+        'No SDK version was found. '
+        'Are you in a Chromium source tree instead of Chromium OS?\n\n'
+        'Please change to a directory inside your Chromium OS source tree\n'
+        'and retry.  If you need to setup a Chromium OS source tree, see\n'
+        '  http://www.chromium.org/chromium-os/developer-guide')
+
   _ReExecuteIfNeeded([sys.argv[0]] + argv)
   if options.ns_pid:
     first_pid = namespaces.CreatePidNs()