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

Uncaught exceptions get two stack traces #718

Merged
merged 1 commit into from
Aug 20, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion sky/engine/core/script/dart_service_isolate/server.dart
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ class Server {
_notifyServerState(ip, _server.port);
return this;
}).catchError((e, st) {
print('Could not start Observatory HTTP server:\n$e\n$st\n');
_notifyServerState("", 0);
return this;
});
Expand Down
7 changes: 4 additions & 3 deletions sky/engine/tonic/dart_error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ const char kInvalidArgument[] = "Invalid argument.";

bool LogIfError(Dart_Handle handle) {
if (Dart_IsError(handle)) {
LOG(ERROR) << Dart_GetError(handle);

// Only unhandled exceptions have stacktraces.
if (!Dart_ErrorHasException(handle))
if (!Dart_ErrorHasException(handle)) {
LOG(ERROR) << Dart_GetError(handle);
return true;
}

Dart_Handle stacktrace = Dart_ErrorGetStacktrace(handle);
const char* stacktrace_cstr = "";
Dart_StringToCString(Dart_ToString(stacktrace), &stacktrace_cstr);
LOG(ERROR) << "Unhandled exception:";
LOG(ERROR) << stacktrace_cstr;
return true;
}
Expand Down
8 changes: 6 additions & 2 deletions sky/shell/dart/dart_library_provider_files.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ base::FilePath SimplifyPath(const base::FilePath& path) {
DartLibraryProviderFiles::DartLibraryProviderFiles(
const base::FilePath& package_root)
: package_root_(package_root) {
CHECK(base::DirectoryExists(package_root_)) << "Invalid --package-root "
<< "\"" << package_root_.LossyDisplayName() << "\"";
if (package_root_.empty())
package_root_ = base::FilePath(FILE_PATH_LITERAL("packages"));
if (!base::DirectoryExists(package_root_))
package_root_ = base::FilePath();
}

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

Expand Down