From 26f3c71132c43fc98124755b0dc9bae820a921c0 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Mon, 9 Nov 2015 12:12:57 -0800 Subject: [PATCH] Improve error handling in sky_snapshoter Now we print a more sensible error message and exit with an error instead of appearing to crash. Fixes https://github.com/flutter/flutter/issues/53 --- engine/src/flutter/sky/BUILD.gn | 1 + engine/src/flutter/sky/tools/sky_snapshot/loader.cc | 5 ++++- engine/src/flutter/sky/tools/sky_snapshot/main.cc | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/engine/src/flutter/sky/BUILD.gn b/engine/src/flutter/sky/BUILD.gn index 23320f7f69..e062bdcbc6 100644 --- a/engine/src/flutter/sky/BUILD.gn +++ b/engine/src/flutter/sky/BUILD.gn @@ -10,6 +10,7 @@ group("sky") { "//sky/engine/wtf:unittests($host_toolchain)", "//sky/packages", "//sky/shell", + "//sky/tools/sky_snapshot", ] if (is_android) { diff --git a/engine/src/flutter/sky/tools/sky_snapshot/loader.cc b/engine/src/flutter/sky/tools/sky_snapshot/loader.cc index c91f756fdc..e1c190c118 100644 --- a/engine/src/flutter/sky/tools/sky_snapshot/loader.cc +++ b/engine/src/flutter/sky/tools/sky_snapshot/loader.cc @@ -18,7 +18,10 @@ namespace { std::string Fetch(const std::string& url) { base::FilePath path(url); std::string source; - CHECK(base::ReadFileToString(path, &source)) << url; + if (!base::ReadFileToString(path, &source)) { + fprintf(stderr, "error: Unable to find Dart library '%s'.\n", url.c_str()); + exit(1); + } return source; } diff --git a/engine/src/flutter/sky/tools/sky_snapshot/main.cc b/engine/src/flutter/sky/tools/sky_snapshot/main.cc index 3d095b2840..65c8477b93 100644 --- a/engine/src/flutter/sky/tools/sky_snapshot/main.cc +++ b/engine/src/flutter/sky/tools/sky_snapshot/main.cc @@ -19,9 +19,9 @@ #include "sky/tools/sky_snapshot/vm.h" void Usage() { - std::cerr << "Usage: sky_packager" + std::cerr << "Usage: sky_snapshot" << " --" << switches::kPackageRoot << " --" << switches::kSnapshot - << " " << std::endl; + << " " << std::endl; } void WriteSnapshot(base::FilePath path) {