Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 7dfac2f

Browse files
committed
Merge pull request #718 from abarth/one_stack_trace
Uncaught exceptions get two stack traces
2 parents a5579f2 + 7f0a289 commit 7dfac2f

3 files changed

Lines changed: 10 additions & 6 deletions

File tree

sky/engine/core/script/dart_service_isolate/server.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ class Server {
179179
_notifyServerState(ip, _server.port);
180180
return this;
181181
}).catchError((e, st) {
182-
print('Could not start Observatory HTTP server:\n$e\n$st\n');
183182
_notifyServerState("", 0);
184183
return this;
185184
});

sky/engine/tonic/dart_error.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,16 @@ const char kInvalidArgument[] = "Invalid argument.";
1616

1717
bool LogIfError(Dart_Handle handle) {
1818
if (Dart_IsError(handle)) {
19-
LOG(ERROR) << Dart_GetError(handle);
20-
2119
// Only unhandled exceptions have stacktraces.
22-
if (!Dart_ErrorHasException(handle))
20+
if (!Dart_ErrorHasException(handle)) {
21+
LOG(ERROR) << Dart_GetError(handle);
2322
return true;
23+
}
2424

2525
Dart_Handle stacktrace = Dart_ErrorGetStacktrace(handle);
2626
const char* stacktrace_cstr = "";
2727
Dart_StringToCString(Dart_ToString(stacktrace), &stacktrace_cstr);
28+
LOG(ERROR) << "Unhandled exception:";
2829
LOG(ERROR) << stacktrace_cstr;
2930
return true;
3031
}

sky/shell/dart/dart_library_provider_files.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ base::FilePath SimplifyPath(const base::FilePath& path) {
4242
DartLibraryProviderFiles::DartLibraryProviderFiles(
4343
const base::FilePath& package_root)
4444
: package_root_(package_root) {
45-
CHECK(base::DirectoryExists(package_root_)) << "Invalid --package-root "
46-
<< "\"" << package_root_.LossyDisplayName() << "\"";
45+
if (package_root_.empty())
46+
package_root_ = base::FilePath(FILE_PATH_LITERAL("packages"));
47+
if (!base::DirectoryExists(package_root_))
48+
package_root_ = base::FilePath();
4749
}
4850

4951
DartLibraryProviderFiles::~DartLibraryProviderFiles() {
@@ -65,6 +67,8 @@ void DartLibraryProviderFiles::GetLibraryAsStream(
6567
std::string DartLibraryProviderFiles::CanonicalizePackageURL(std::string url) {
6668
DCHECK(base::StartsWithASCII(url, "package:", true));
6769
base::ReplaceFirstSubstringAfterOffset(&url, 0, "package:", "");
70+
CHECK(!package_root_.empty())
71+
<< "Cannot import packages without a valid --package-root";
6872
return package_root_.Append(url).AsUTF8Unsafe();
6973
}
7074

0 commit comments

Comments
 (0)