diff --git a/base/cvd/cuttlefish/common/frontend/socket_vsock_proxy/socket_vsock_proxy.cpp b/base/cvd/cuttlefish/common/frontend/socket_vsock_proxy/socket_vsock_proxy.cpp index c49cd09312b..bf51eff3b36 100644 --- a/base/cvd/cuttlefish/common/frontend/socket_vsock_proxy/socket_vsock_proxy.cpp +++ b/base/cvd/cuttlefish/common/frontend/socket_vsock_proxy/socket_vsock_proxy.cpp @@ -185,7 +185,7 @@ static Result ListenEventsAndProxy(int events_fd, // recoverable. if (!received_event.ok()) { LOG(ERROR) << "Failed reading kernel log event: " - << received_event.error().FormatForEnv(); + << received_event.error(); continue; } if (!(*received_event)) { @@ -248,7 +248,7 @@ int main(int argc, char* argv[]) { auto result = cuttlefish::socket_proxy::Main(); if (!result.ok()) { - LOG(FATAL) << "Failed to proxy: " << result.error().FormatForEnv(); + LOG(FATAL) << "Failed to proxy: " << result.error(); } return 0; diff --git a/base/cvd/cuttlefish/common/libs/utils/archive.cpp b/base/cvd/cuttlefish/common/libs/utils/archive.cpp index f1e1be80823..d9c9cafaf07 100644 --- a/base/cvd/cuttlefish/common/libs/utils/archive.cpp +++ b/base/cvd/cuttlefish/common/libs/utils/archive.cpp @@ -141,8 +141,7 @@ std::string ExtractArchiveToMemory(const std::string& archive_filepath, if (!stdout_str.ok()) { LOG(ERROR) << "Could not extract \"" << archive_member << "\" from \"" - << archive_filepath - << "\" to memory: " << stdout_str.error().FormatForEnv(); + << archive_filepath << "\" to memory: " << stdout_str.error(); return ""; } return *stdout_str; @@ -159,7 +158,7 @@ std::vector ArchiveContents(const std::string& archive) { return android::base::Split(*bsdtar_output, "\n"); } else { LOG(ERROR) << "`bsdtar -tf '" << archive - << "'`failed: " << bsdtar_output.error().FormatForEnv(); + << "'`failed: " << bsdtar_output.error(); return {}; } } diff --git a/base/cvd/cuttlefish/common/libs/utils/files_test.cpp b/base/cvd/cuttlefish/common/libs/utils/files_test.cpp index 1dfe115aea7..bfd9d4d4bf0 100644 --- a/base/cvd/cuttlefish/common/libs/utils/files_test.cpp +++ b/base/cvd/cuttlefish/common/libs/utils/files_test.cpp @@ -53,7 +53,7 @@ class FilesTests : public ::testing::Test { void SetUp() override { Result result = CreateTestDirs(); if (!result.ok()) { - FAIL() << result.error().FormatForEnv(); + FAIL() << result.error(); } } diff --git a/base/cvd/cuttlefish/common/libs/utils/subprocess.cpp b/base/cvd/cuttlefish/common/libs/utils/subprocess.cpp index 0320ff8276e..0c06239107f 100644 --- a/base/cvd/cuttlefish/common/libs/utils/subprocess.cpp +++ b/base/cvd/cuttlefish/common/libs/utils/subprocess.cpp @@ -421,7 +421,7 @@ Subprocess Command::Start(SubprocessOptions options) const { if (!prerequisiteResult.ok()) { LOG(ERROR) << "Failed to check prerequisites: " - << prerequisiteResult.error().FormatForEnv(); + << prerequisiteResult.error(); return Subprocess(-1, {}); } } diff --git a/base/cvd/cuttlefish/host/commands/assemble_cvd/assemble_cvd.cc b/base/cvd/cuttlefish/host/commands/assemble_cvd/assemble_cvd.cc index 2911ea88dd6..674adcba770 100644 --- a/base/cvd/cuttlefish/host/commands/assemble_cvd/assemble_cvd.cc +++ b/base/cvd/cuttlefish/host/commands/assemble_cvd/assemble_cvd.cc @@ -674,6 +674,6 @@ int main(int argc, char** argv) { if (res.ok()) { return *res; } - LOG(ERROR) << "assemble_cvd failed: \n" << res.error().FormatForEnv(); + LOG(ERROR) << "assemble_cvd failed: \n" << res.error(); abort(); } diff --git a/base/cvd/cuttlefish/host/commands/assemble_cvd/boot_config.cc b/base/cvd/cuttlefish/host/commands/assemble_cvd/boot_config.cc index 709a92b865a..0ef2ed43f8d 100644 --- a/base/cvd/cuttlefish/host/commands/assemble_cvd/boot_config.cc +++ b/base/cvd/cuttlefish/host/commands/assemble_cvd/boot_config.cc @@ -198,7 +198,7 @@ Result PrepareBootEnvImage( "Unable to delete the old env image"); LOG(DEBUG) << "Updated bootloader environment image."; } else if (Result rs = RemoveFile(tmp_boot_env_image_path); !rs.ok()) { - LOG(WARNING) << rs.error().FormatForEnv(); + LOG(WARNING) << rs.error(); } return {}; diff --git a/base/cvd/cuttlefish/host/commands/assemble_cvd/boot_image_utils.cc b/base/cvd/cuttlefish/host/commands/assemble_cvd/boot_image_utils.cc index 11defedaa3e..3698d6905cf 100644 --- a/base/cvd/cuttlefish/host/commands/assemble_cvd/boot_image_utils.cc +++ b/base/cvd/cuttlefish/host/commands/assemble_cvd/boot_image_utils.cc @@ -104,7 +104,7 @@ bool DeleteTmpFileIfNotChanged(const std::string& tmp_file, const std::string& c } else { LOG(DEBUG) << "Didn't update " << current_file; if (Result res = RemoveFile(tmp_file); !res.ok()) { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); } } @@ -176,7 +176,7 @@ void UnpackRamdisk(const std::string& original_ramdisk_path, << original_ramdisk_path << "'."; } const auto ret = EnsureDirectoryExists(ramdisk_stage_dir); - CHECK(ret.ok()) << ret.error().FormatForEnv(); + CHECK(ret.ok()) << ret.error(); SharedFD input = SharedFD::Open(original_ramdisk_path + kCpioExt, O_RDONLY); int cpio_status; @@ -245,7 +245,7 @@ bool UnpackVendorBootImageIfNotUnpacked( Result> unpack_files = DirectoryContents(unpack_dir); if (!unpack_files.ok()) { - LOG(ERROR) << "No unpacked files: " << unpack_files.error().FormatForEnv(); + LOG(ERROR) << "No unpacked files: " << unpack_files.error(); return false; } for (const std::string& unpacked : *unpack_files) { diff --git a/base/cvd/cuttlefish/host/commands/assemble_cvd/clean.cc b/base/cvd/cuttlefish/host/commands/assemble_cvd/clean.cc index 6817540aefb..a7e12929e26 100644 --- a/base/cvd/cuttlefish/host/commands/assemble_cvd/clean.cc +++ b/base/cvd/cuttlefish/host/commands/assemble_cvd/clean.cc @@ -122,7 +122,7 @@ Result CleanPriorFiles(const std::vector& paths, "Instance directory files in use. Try `cvd reset`? Observed PIDs: {}", fmt::join(pids, ", ")); } else { - LOG(ERROR) << "Failed to run `lsof`: " << lsof_out.error().FormatForEnv(); + LOG(ERROR) << "Failed to run `lsof`: " << lsof_out.error(); } } diff --git a/base/cvd/cuttlefish/host/commands/assemble_cvd/create_dynamic_disk_files.cc b/base/cvd/cuttlefish/host/commands/assemble_cvd/create_dynamic_disk_files.cc index 2678a7a927a..b76fa5253a2 100644 --- a/base/cvd/cuttlefish/host/commands/assemble_cvd/create_dynamic_disk_files.cc +++ b/base/cvd/cuttlefish/host/commands/assemble_cvd/create_dynamic_disk_files.cc @@ -109,7 +109,7 @@ Result CreateDynamicDiskFiles( LOG(DEBUG) << "Found image zip: " << *img_zip; } else { LOG(DEBUG) << "Error accessing '-img-*.zip', expected for a local build."; - LOG(DEBUG) << img_zip.error().FormatForEnv(); + LOG(DEBUG) << img_zip.error(); } std::optional chrome_os_state = diff --git a/base/cvd/cuttlefish/host/commands/assemble_cvd/graphics_flags.cc b/base/cvd/cuttlefish/host/commands/assemble_cvd/graphics_flags.cc index 74d37965066..549579f6888 100644 --- a/base/cvd/cuttlefish/host/commands/assemble_cvd/graphics_flags.cc +++ b/base/cvd/cuttlefish/host/commands/assemble_cvd/graphics_flags.cc @@ -535,7 +535,7 @@ GetGraphicsAvailabilityWithSubprocessCheck() { if (!graphics_detector_stdout.ok()) { LOG(ERROR) << "Failed to run graphics detector, assuming no availability: \n" - << graphics_detector_stdout.error().FormatForEnv(); + << graphics_detector_stdout.error(); return {}; } LOG(DEBUG) << *graphics_detector_stdout; @@ -545,7 +545,7 @@ GetGraphicsAvailabilityWithSubprocessCheck() { if (!graphics_availability_content_result.ok()) { LOG(ERROR) << "Failed to read graphics availability from file " << graphics_availability_file.path << ":" - << graphics_availability_content_result.error().FormatForEnv() + << graphics_availability_content_result.error() << ". Assuming no availability."; return {}; } diff --git a/base/cvd/cuttlefish/host/commands/assemble_cvd/vendor_dlkm_utils.cc b/base/cvd/cuttlefish/host/commands/assemble_cvd/vendor_dlkm_utils.cc index c1e1a62914e..7ca0f396f30 100644 --- a/base/cvd/cuttlefish/host/commands/assemble_cvd/vendor_dlkm_utils.cc +++ b/base/cvd/cuttlefish/host/commands/assemble_cvd/vendor_dlkm_utils.cc @@ -563,7 +563,7 @@ bool MoveIfChanged(const std::string& src, const std::string& dst) { } const auto ret = RenameFile(src, dst); if (!ret.ok()) { - LOG(ERROR) << ret.error().FormatForEnv(); + LOG(ERROR) << ret.error(); return false; } return true; diff --git a/base/cvd/cuttlefish/host/commands/casimir_control_server/main.cpp b/base/cvd/cuttlefish/host/commands/casimir_control_server/main.cpp index dda30d13a06..8e6ae75d23e 100644 --- a/base/cvd/cuttlefish/host/commands/casimir_control_server/main.cpp +++ b/base/cvd/cuttlefish/host/commands/casimir_control_server/main.cpp @@ -76,7 +76,7 @@ Status ResultToStatus(Result res) { if (res.ok()) { return Status::OK; } else { - LOG(ERROR) << "RPC failed: " << res.error().FormatForEnv(); + LOG(ERROR) << "RPC failed: " << res.error(); return Status(StatusCode::INTERNAL, res.error().FormatForEnv(/* color = */ false)); } diff --git a/base/cvd/cuttlefish/host/commands/cvd/cli/commands/bugreport.cpp b/base/cvd/cuttlefish/host/commands/cvd/cli/commands/bugreport.cpp index afd851c1f64..48af6bfa614 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/cli/commands/bugreport.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/cli/commands/bugreport.cpp @@ -156,8 +156,7 @@ Result CvdBugreportCommandHandler::Handle(const CommandRequest& request) { auto result = AddFetchLogIfPresent(instance_group, output_file); if (!result.ok()) { - LOG(ERROR) << "Failed to add fetch log to bugreport: " - << result.error().FormatForEnv(); + LOG(ERROR) << "Failed to add fetch log to bugreport: " << result.error(); } return {}; diff --git a/base/cvd/cuttlefish/host/commands/cvd/cli/commands/create.cpp b/base/cvd/cuttlefish/host/commands/cvd/cli/commands/create.cpp index 8de208ba246..f8371cfa114 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/cli/commands/create.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/cli/commands/create.cpp @@ -346,7 +346,7 @@ Result CvdCreateCommandHandler::Handle(const CommandRequest& request) { auto symlink_res = CreateSymlinks(group); if (!symlink_res.ok()) { LOG(ERROR) << "Failed to create symlinks for default group: " - << symlink_res.error().FormatForEnv(); + << symlink_res.error(); } } } diff --git a/base/cvd/cuttlefish/host/commands/cvd/cli/commands/help.cpp b/base/cvd/cuttlefish/host/commands/cvd/cli/commands/help.cpp index 84051340db2..45f4708d35a 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/cli/commands/help.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/cli/commands/help.cpp @@ -103,7 +103,7 @@ class CvdHelpHandler : public CvdCommandHandler { CommandRequest GetLookupRequest(const std::string& arg) { auto result = CommandRequestBuilder().AddArguments({"cvd", arg}).Build(); CHECK(result.ok()) << "Failed to build cvd command request" - << result.error().FormatForEnv(); + << result.error(); return result.value(); } diff --git a/base/cvd/cuttlefish/host/commands/cvd/cli/commands/remove.cpp b/base/cvd/cuttlefish/host/commands/cvd/cli/commands/remove.cpp index 51599b217df..a4b46840c5b 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/cli/commands/remove.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/cli/commands/remove.cpp @@ -67,7 +67,7 @@ class RemoveCvdCommandHandler : public CvdCommandHandler { auto stop_res = StopGroup(group, request); if (!stop_res.ok()) { - LOG(ERROR) << stop_res.error().FormatForEnv(); + LOG(ERROR) << stop_res.error(); LOG(ERROR) << "Unable to stop devices first, run `cvd reset` to forcibly " "kill any remaining device processes."; } diff --git a/base/cvd/cuttlefish/host/commands/cvd/cli/commands/screen_recording.cpp b/base/cvd/cuttlefish/host/commands/cvd/cli/commands/screen_recording.cpp index deeda55fd35..026f048dad6 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/cli/commands/screen_recording.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/cli/commands/screen_recording.cpp @@ -96,7 +96,7 @@ Result StartStopRecording(const RecordingFlags& flags, if (!result.ok()) { LOG(ERROR) << "Failed to " << flags.subcmd << " screen recording for instance " << instance.name() << ": " - << result.error().FormatForEnv(); + << result.error(); some_failed = true; } } @@ -121,7 +121,7 @@ Result ListRecordings(const LocalInstanceGroup& group, recordings = std::move(*result); } else { LOG(ERROR) << "Failed to list screen recording for instance " - << instance.name() << ": " << result.error().FormatForEnv(); + << instance.name() << ": " << result.error(); some_failed = true; } for (const std::string& recording : recordings) { diff --git a/base/cvd/cuttlefish/host/commands/cvd/cli/commands/start.cpp b/base/cvd/cuttlefish/host/commands/cvd/cli/commands/start.cpp index 0eba2d4b527..3a4f04331d4 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/cli/commands/start.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/cli/commands/start.cpp @@ -472,8 +472,7 @@ Result CvdStartCommandHandler::Handle(const CommandRequest& request) { LOG(WARNING) << strsignal(signal) << " signal received, cleanning up"; auto interrupt_res = subprocess_waiter_.Interrupt(); if (!interrupt_res.ok()) { - LOG(ERROR) << "Failed to stop subprocesses: " - << interrupt_res.error().FormatForEnv(); + LOG(ERROR) << "Failed to stop subprocesses: " << interrupt_res.error(); LOG(ERROR) << "Devices may still be executing in the background, run " "`cvd reset` to ensure a clean state"; } @@ -481,8 +480,7 @@ Result CvdStartCommandHandler::Handle(const CommandRequest& request) { group.SetAllStates(cvd::INSTANCE_STATE_CANCELLED); auto update_res = instance_manager_.UpdateInstanceGroup(group); if (!update_res.ok()) { - LOG(ERROR) << "Failed to update group status: " - << update_res.error().FormatForEnv(); + LOG(ERROR) << "Failed to update group status: " << update_res.error(); } // It's technically possible for the group's state to be set to // "running" before abort has a chance to run, but that can only happen @@ -528,7 +526,7 @@ Result CvdStartCommandHandler::LaunchDevice( if (!conn_res.ok()) { LOG(ERROR) << "Failed to pre-register devices with operator, group " "information won't show in the UI: " - << conn_res.error().FormatForEnv(); + << conn_res.error(); } LOG(INFO) << "launch command: " << launch_command; @@ -565,7 +563,7 @@ Result CvdStartCommandHandler::LaunchDeviceInterruptible( auto symlink_config_res = SymlinkPreviousConfig(group.HomeDir()); if (!symlink_config_res.ok()) { LOG(ERROR) << "Failed to symlink the config file at system wide home: " - << symlink_config_res.error().FormatForEnv(); + << symlink_config_res.error(); } Result start_res = LaunchDevice(std::move(command), group, envs, request); diff --git a/base/cvd/cuttlefish/host/commands/cvd/fetch/substitute.cc b/base/cvd/cuttlefish/host/commands/cvd/fetch/substitute.cc index f20cea3b935..a10e929c467 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/fetch/substitute.cc +++ b/base/cvd/cuttlefish/host/commands/cvd/fetch/substitute.cc @@ -97,7 +97,7 @@ Result SubstituteWithFlag( } Result symlink_res = Symlink(path, to_substitute); if (!symlink_res.ok()) { - LOG(ERROR) << symlink_res.error().FormatForEnv(); + LOG(ERROR) << symlink_res.error(); substitution_error = true; return false; } diff --git a/base/cvd/cuttlefish/host/commands/cvd/instances/instance_database.cpp b/base/cvd/cuttlefish/host/commands/cvd/instances/instance_database.cpp index ae1689ad48f..b21d0d56df5 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/instances/instance_database.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/instances/instance_database.cpp @@ -220,7 +220,7 @@ std::vector InstanceDatabase::FindGroups( } auto group_res = LocalInstanceGroup::Create(group); CHECK(group_res.ok()) << "Instance group from database fails validation: " - << group_res.error().FormatForEnv(); + << group_res.error(); ret.push_back(*group_res); } return ret; diff --git a/base/cvd/cuttlefish/host/commands/cvd/instances/instance_manager.cpp b/base/cvd/cuttlefish/host/commands/cvd/instances/instance_manager.cpp index b6fc8e77947..086821fca84 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/instances/instance_manager.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/instances/instance_manager.cpp @@ -190,8 +190,7 @@ Result InstanceManager::RemoveInstanceGroup(LocalInstanceGroup group) { continue; } if (auto res = lock_manager_.RemoveLockFile(instance.id()); !res.ok()) { - LOG(ERROR) << "Failed to remove instance id lock: " - << res.error().FormatForEnv(); + LOG(ERROR) << "Failed to remove instance id lock: " << res.error(); } } CF_EXPECT(RemoveGroupDirectory(group)); @@ -244,7 +243,7 @@ Result InstanceManager::Clear() { auto stop_result = StopInstanceGroup(group, std::chrono::seconds(5), InstanceDirActionOnStop::Clear); if (!stop_result.ok()) { - LOG(ERROR) << stop_result.error().FormatForEnv(); + LOG(ERROR) << stop_result.error(); } } for (auto instance : group.Instances()) { @@ -254,16 +253,16 @@ Result InstanceManager::Clear() { auto res = lock_manager_.RemoveLockFile(instance.id()); if (!res.ok()) { LOG(ERROR) << "Failed to remove lock file for instance: " - << res.error().FormatForEnv(); + << res.error(); } } std::string runtime_link = group.HomeDir() + "/cuttlefish_runtime"; if (Result res = RemoveFile(runtime_link);!res.ok()) { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); } std::string config_link = group.HomeDir() + config_json_name; if (Result res = RemoveFile(config_link);!res.ok()) { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); } // TODO: b/471069557 - diagnose unused Result unused = RemoveGroupDirectory(group); diff --git a/base/cvd/cuttlefish/host/commands/cvd/instances/run_cvd_proc_collector.cpp b/base/cvd/cuttlefish/host/commands/cvd/instances/run_cvd_proc_collector.cpp index c5fa5c94072..04224411e97 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/instances/run_cvd_proc_collector.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/instances/run_cvd_proc_collector.cpp @@ -78,7 +78,7 @@ static Result StopCvdPath(const RunCvdProcInfo& info) { if (result.ok()) { return *result; } - LOG(ERROR) << result.error().FormatForEnv(); + LOG(ERROR) << result.error(); } else { LOG(ERROR) << "run_cvd host tool directory was not able to be guessed."; } diff --git a/base/cvd/cuttlefish/host/commands/cvd/instances/stop.cpp b/base/cvd/cuttlefish/host/commands/cvd/instances/stop.cpp index d2056bf2f5a..18025700a95 100644 --- a/base/cvd/cuttlefish/host/commands/cvd/instances/stop.cpp +++ b/base/cvd/cuttlefish/host/commands/cvd/instances/stop.cpp @@ -90,7 +90,7 @@ Result RunStopCvdAll(bool clear_runtime_dirs) { .clear_runtime_dirs = clear_runtime_dirs, }); if (!stop_cvd_result.ok()) { - LOG(ERROR) << stop_cvd_result.error().FormatForEnv(); + LOG(ERROR) << stop_cvd_result.error(); continue; } } @@ -158,7 +158,7 @@ Result DeleteLockFile(const GroupProcInfo& group_info) { } else { all_success = false; LOG(ERROR) << "Failed to remove the lock file '" << lock_file_path - << "': " << res.error().FormatForEnv(); + << "': " << res.error(); } } } @@ -190,7 +190,7 @@ Result KillAllRunCvds() { << " run_cvd processes still remain, will stop forcefully"; for (pid_t group_pid : run_cvd_pids) { if (Result result = SendSignal(group_pid); !result.ok()) { - LOG(ERROR) << result.error().FormatForEnv(); + LOG(ERROR) << result.error(); } } return {}; @@ -212,7 +212,7 @@ Result DeleteAllOwnedInstanceLocks() { continue; } if (Result res = RemoveFile(lock_file_path); !res.ok()) { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); } } return {}; @@ -222,15 +222,15 @@ Result DeleteAllOwnedInstanceLocks() { Result KillAllCuttlefishInstances(bool clear_runtime_dirs) { if (Result res = RunStopCvdAll(clear_runtime_dirs); !res.ok()) { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); } if (Result res = KillAllRunCvds(); !res.ok()) { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); } if (Result res = DeleteAllOwnedInstanceLocks(); !res.ok()) { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); } return {}; diff --git a/base/cvd/cuttlefish/host/commands/cvd_env/main.cc b/base/cvd/cuttlefish/host/commands/cvd_env/main.cc index d554a49438b..c1497538a0d 100644 --- a/base/cvd/cuttlefish/host/commands/cvd_env/main.cc +++ b/base/cvd/cuttlefish/host/commands/cvd_env/main.cc @@ -122,6 +122,6 @@ Result CvdEnvMain(int argc, char** argv) { int main(int argc, char** argv) { const auto& ret = cuttlefish::CvdEnvMain(argc, argv); - CHECK(ret.ok()) << ret.error().FormatForEnv(); + CHECK(ret.ok()) << ret.error(); return 0; } diff --git a/base/cvd/cuttlefish/host/commands/cvdalloc/cvdalloc.cpp b/base/cvd/cuttlefish/host/commands/cvdalloc/cvdalloc.cpp index 7a2b5263c12..8e3ad5af847 100644 --- a/base/cvd/cuttlefish/host/commands/cvdalloc/cvdalloc.cpp +++ b/base/cvd/cuttlefish/host/commands/cvdalloc/cvdalloc.cpp @@ -148,7 +148,7 @@ Result CvdallocMain(int argc, char *argv[]) { int main(int argc, char *argv[]) { auto res = cuttlefish::CvdallocMain(argc, argv); if (!res.ok()) { - LOG(ERROR) << "cvdalloc failed: \n" << res.error().FormatForEnv(); + LOG(ERROR) << "cvdalloc failed: \n" << res.error(); abort(); } diff --git a/base/cvd/cuttlefish/host/commands/defaults/defaults.cpp b/base/cvd/cuttlefish/host/commands/defaults/defaults.cpp index 23b7e72f13e..5ffd08a401c 100644 --- a/base/cvd/cuttlefish/host/commands/defaults/defaults.cpp +++ b/base/cvd/cuttlefish/host/commands/defaults/defaults.cpp @@ -135,7 +135,7 @@ Result DefaultsMain(int argc, char *argv[]) { int main(int argc, char *argv[]) { auto res = cuttlefish::DefaultsMain(argc, argv); if (!res.ok()) { - LOG(ERROR) << "defaults failed: \n" << res.error().FormatForEnv(); + LOG(ERROR) << "defaults failed: \n" << res.error(); abort(); } diff --git a/base/cvd/cuttlefish/host/commands/display/main.cpp b/base/cvd/cuttlefish/host/commands/display/main.cpp index 274ace57dd6..aaa1d005ea6 100644 --- a/base/cvd/cuttlefish/host/commands/display/main.cpp +++ b/base/cvd/cuttlefish/host/commands/display/main.cpp @@ -164,7 +164,7 @@ Result DoRemove(std::vector& args) { }; auto parse_res = ConsumeFlags(remove_displays_flags, args); if (!parse_res.ok()) { - std::cerr << parse_res.error().FormatForEnv() << std::endl; + std::cerr << parse_res.error() << std::endl; std::cerr << "Failed to parse flags. Usage:" << std::endl; std::cerr << kRemoveUsage << std::endl; return 1; @@ -201,7 +201,7 @@ Result DoScreenshot(std::vector& args) { }; auto parse_res = ConsumeFlags(screenshot_flags, args); if (!parse_res.ok()) { - std::cerr << parse_res.error().FormatForEnv() << std::endl; + std::cerr << parse_res.error() << std::endl; std::cerr << "Failed to parse flags. Usage:" << std::endl; std::cerr << kScreenshotUsage << std::endl; return 1; @@ -257,7 +257,7 @@ int DisplayMain(int argc, char** argv) { auto result = command_func_it->second(args); if (!result.ok()) { - std::cerr << result.error().FormatForEnv(); + std::cerr << result.error(); return 1; } return result.value(); diff --git a/base/cvd/cuttlefish/host/commands/health/health.cpp b/base/cvd/cuttlefish/host/commands/health/health.cpp index c473f80257d..27412e4a489 100644 --- a/base/cvd/cuttlefish/host/commands/health/health.cpp +++ b/base/cvd/cuttlefish/host/commands/health/health.cpp @@ -129,7 +129,7 @@ int main(int argc, char** argv) { if (res.ok()) { return 0; } else { - LOG(ERROR) << "goldfish battery failed: " << res.error().FormatForEnv(); + LOG(ERROR) << "goldfish battery failed: " << res.error(); return 1; } } diff --git a/base/cvd/cuttlefish/host/commands/host_bugreport/main.cc b/base/cvd/cuttlefish/host/commands/host_bugreport/main.cc index 81f9c108c10..d80f5611b06 100644 --- a/base/cvd/cuttlefish/host/commands/host_bugreport/main.cc +++ b/base/cvd/cuttlefish/host/commands/host_bugreport/main.cc @@ -215,7 +215,7 @@ Result CvdHostBugreportMain(int argc, char** argv) { if (Result res = RemoveFile(log_filename); !res.ok()) { LOG(INFO) << "Failed to remove host bug report log file '" << log_filename - << "': " << res.error().FormatForEnv(); + << "': " << res.error(); } return {}; @@ -226,6 +226,6 @@ Result CvdHostBugreportMain(int argc, char** argv) { int main(int argc, char** argv) { auto result = cuttlefish::CvdHostBugreportMain(argc, argv); - CHECK(result.ok()) << result.error().FormatForEnv(); + CHECK(result.ok()) << result.error(); return 0; } diff --git a/base/cvd/cuttlefish/host/commands/metrics/send.cc b/base/cvd/cuttlefish/host/commands/metrics/send.cc index 65bbfa0b32f..c0e1878ae12 100644 --- a/base/cvd/cuttlefish/host/commands/metrics/send.cc +++ b/base/cvd/cuttlefish/host/commands/metrics/send.cc @@ -64,7 +64,7 @@ MetricsExitCodes PostRequest(HttpClient& http_client, const std::string& output, Result> http_res = HttpPostToString(http_client, clearcut_url, output); if (!http_res.ok()) { - LOG(ERROR) << "HTTP command failed: " << http_res.error().FormatForEnv(); + LOG(ERROR) << "HTTP command failed: " << http_res.error(); return MetricsExitCodes::kMetricsError; } diff --git a/base/cvd/cuttlefish/host/commands/metrics_launcher/metrics_launcher.cpp b/base/cvd/cuttlefish/host/commands/metrics_launcher/metrics_launcher.cpp index a2645ecf214..b2495872516 100644 --- a/base/cvd/cuttlefish/host/commands/metrics_launcher/metrics_launcher.cpp +++ b/base/cvd/cuttlefish/host/commands/metrics_launcher/metrics_launcher.cpp @@ -67,7 +67,7 @@ int main(int argc, char** argv) { cuttlefish::Result result = cuttlefish::MetricsLauncherMain(); if (!result.ok()) { - LOG(ERROR) << result.error().FormatForEnv(); + LOG(ERROR) << result.error(); return EXIT_FAILURE; } return EXIT_SUCCESS; diff --git a/base/cvd/cuttlefish/host/commands/mkenvimage_slim/mkenvimage_slim.cc b/base/cvd/cuttlefish/host/commands/mkenvimage_slim/mkenvimage_slim.cc index e244192b505..dafaa13be30 100644 --- a/base/cvd/cuttlefish/host/commands/mkenvimage_slim/mkenvimage_slim.cc +++ b/base/cvd/cuttlefish/host/commands/mkenvimage_slim/mkenvimage_slim.cc @@ -80,7 +80,7 @@ Result MkenvimageSlimMain(int argc, char** argv) { } else if (FLAGS_env_size != WriteAll(output_fd, (char*)env_buffer.data(), FLAGS_env_size)) { if (Result res = RemoveFile(FLAGS_output_path); !res.ok()) { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); } return CF_ERR("Couldn't complete write to " + FLAGS_output_path); } @@ -94,6 +94,6 @@ int main(int argc, char** argv) { if (res.ok()) { return *res; } - LOG(ERROR) << "mkenvimage_slim failed: \n" << res.error().FormatForEnv(); + LOG(ERROR) << "mkenvimage_slim failed: \n" << res.error(); abort(); } diff --git a/base/cvd/cuttlefish/host/commands/powerbtn_cvd/powerbtn_cvd.cc b/base/cvd/cuttlefish/host/commands/powerbtn_cvd/powerbtn_cvd.cc index 4fb08f1e32a..baccb4d6ee9 100644 --- a/base/cvd/cuttlefish/host/commands/powerbtn_cvd/powerbtn_cvd.cc +++ b/base/cvd/cuttlefish/host/commands/powerbtn_cvd/powerbtn_cvd.cc @@ -52,7 +52,7 @@ int main(int argc, char** argv) { google::ParseCommandLineFlags(&argc, &argv, true); cuttlefish::Result result = cuttlefish::PowerbtnCvdMain(); if (!result.ok()) { - LOG(ERROR) << result.error().FormatForEnv(); + LOG(ERROR) << result.error(); return EXIT_FAILURE; } return EXIT_SUCCESS; diff --git a/base/cvd/cuttlefish/host/commands/powerwash_cvd/powerwash_cvd.cc b/base/cvd/cuttlefish/host/commands/powerwash_cvd/powerwash_cvd.cc index 1d1a6580ba0..9ae7ec91a14 100644 --- a/base/cvd/cuttlefish/host/commands/powerwash_cvd/powerwash_cvd.cc +++ b/base/cvd/cuttlefish/host/commands/powerwash_cvd/powerwash_cvd.cc @@ -72,7 +72,7 @@ int main(int argc, char** argv) { cuttlefish::Result result = cuttlefish::PowerwashCvdMain(); if (!result.ok()) { - LOG(ERROR) << result.error().FormatForEnv(); + LOG(ERROR) << result.error(); return EXIT_FAILURE; } return EXIT_SUCCESS; diff --git a/base/cvd/cuttlefish/host/commands/process_restarter/main.cc b/base/cvd/cuttlefish/host/commands/process_restarter/main.cc index 4badab30f62..73179dadd19 100644 --- a/base/cvd/cuttlefish/host/commands/process_restarter/main.cc +++ b/base/cvd/cuttlefish/host/commands/process_restarter/main.cc @@ -119,7 +119,7 @@ int main(int argc, char** argv) { auto result = cuttlefish::RunProcessRestarter( cuttlefish::ArgsToVec(argc - 1, argv + 1)); if (!result.ok()) { - LOG(DEBUG) << result.error().FormatForEnv(); + LOG(DEBUG) << result.error(); return EXIT_FAILURE; } return result.value(); diff --git a/base/cvd/cuttlefish/host/commands/record_cvd/record_cvd.cc b/base/cvd/cuttlefish/host/commands/record_cvd/record_cvd.cc index 1e38de4f196..deaa100e73e 100644 --- a/base/cvd/cuttlefish/host/commands/record_cvd/record_cvd.cc +++ b/base/cvd/cuttlefish/host/commands/record_cvd/record_cvd.cc @@ -69,7 +69,7 @@ int main(int argc, char* argv[]) { cuttlefish::Result result = cuttlefish::RecordCvdMain(argc, argv); if (!result.ok()) { - LOG(ERROR) << result.error().FormatForEnv(); + LOG(ERROR) << result.error(); return EXIT_FAILURE; } return EXIT_SUCCESS; diff --git a/base/cvd/cuttlefish/host/commands/restart_cvd/restart_cvd.cc b/base/cvd/cuttlefish/host/commands/restart_cvd/restart_cvd.cc index 834fe265bbd..6335519280f 100644 --- a/base/cvd/cuttlefish/host/commands/restart_cvd/restart_cvd.cc +++ b/base/cvd/cuttlefish/host/commands/restart_cvd/restart_cvd.cc @@ -73,7 +73,7 @@ int main(int argc, char** argv) { cuttlefish::Result result = cuttlefish::RestartCvdMain(); if (!result.ok()) { - LOG(ERROR) << result.error().FormatForEnv(); + LOG(ERROR) << result.error(); return EXIT_FAILURE; } return EXIT_SUCCESS; diff --git a/base/cvd/cuttlefish/host/commands/run_cvd/boot_state_machine.cc b/base/cvd/cuttlefish/host/commands/run_cvd/boot_state_machine.cc index 3aeee890843..727e6414796 100644 --- a/base/cvd/cuttlefish/host/commands/run_cvd/boot_state_machine.cc +++ b/base/cvd/cuttlefish/host/commands/run_cvd/boot_state_machine.cc @@ -326,8 +326,8 @@ class CvdBootStateMachine : public SetupFeature, public KernelLogPipeConsumer { [this, restore_complete_pipe_write, restore_complete_stop_read]() { const auto result = vm_manager_.WaitForRestoreComplete(restore_complete_stop_read); - CHECK(result.ok()) << "Failed to wait for restore complete: " - << result.error().FormatForEnv(); + CHECK(result.ok()) + << "Failed to wait for restore complete: " << result.error(); if (!result.value()) { return; } @@ -462,10 +462,10 @@ class CvdBootStateMachine : public SetupFeature, public KernelLogPipeConsumer { break; } auto monitor_res = GetLauncherMonitorFromInstance(instance_, 5); - CHECK(monitor_res.ok()) << monitor_res.error().FormatForEnv(); + CHECK(monitor_res.ok()) << monitor_res.error(); auto fail_res = RunLauncherAction( *monitor_res, LauncherAction::kFail, std::optional()); - CHECK(fail_res.ok()) << fail_res.error().FormatForEnv(); + CHECK(fail_res.ok()) << fail_res.error(); } break; } @@ -552,7 +552,7 @@ class CvdBootStateMachine : public SetupFeature, public KernelLogPipeConsumer { if (!instance_.vcpu_config_path().empty()) { auto res = WattsonRebalanceThreads(instance_.id()); if (!res.ok()) { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); } } } @@ -566,7 +566,7 @@ class CvdBootStateMachine : public SetupFeature, public KernelLogPipeConsumer { monitor::ReadEvent(boot_events_pipe); if (!read_result.ok()) { LOG(ERROR) << "Failed to read a complete kernel log boot event: " - << read_result.error().FormatForEnv(); + << read_result.error(); state_ |= kGuestBootFailed; return MaybeWriteNotification(); } else if (!*read_result) { @@ -581,7 +581,7 @@ class CvdBootStateMachine : public SetupFeature, public KernelLogPipeConsumer { if (!instance_.vcpu_config_path().empty()) { auto res = WattsonRebalanceThreads(instance_.id()); if (!res.ok()) { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); } } } else if ((*read_result)->event == monitor::Event::BootFailed) { diff --git a/base/cvd/cuttlefish/host/commands/run_cvd/main.cc b/base/cvd/cuttlefish/host/commands/run_cvd/main.cc index 76c5d6d955a..3341f3f702d 100644 --- a/base/cvd/cuttlefish/host/commands/run_cvd/main.cc +++ b/base/cvd/cuttlefish/host/commands/run_cvd/main.cc @@ -288,6 +288,6 @@ int main(int argc, char** argv) { if (result.ok()) { return 0; } - LOG(ERROR) << result.error().FormatForEnv(); + LOG(ERROR) << result.error(); abort(); } diff --git a/base/cvd/cuttlefish/host/commands/run_cvd/server_loop_impl.cpp b/base/cvd/cuttlefish/host/commands/run_cvd/server_loop_impl.cpp index b7dbcbc1b35..7e109ad0f03 100644 --- a/base/cvd/cuttlefish/host/commands/run_cvd/server_loop_impl.cpp +++ b/base/cvd/cuttlefish/host/commands/run_cvd/server_loop_impl.cpp @@ -120,7 +120,7 @@ Result ServerLoopImpl::Run() { auto launcher_action_with_info_result = ReadLauncherActionFromFd(client); if (!launcher_action_with_info_result.ok()) { LOG(ERROR) << "Reading launcher command from monitor failed: " - << launcher_action_with_info_result.error().FormatForEnv(); + << launcher_action_with_info_result.error(); break; } auto launcher_action_opt = std::move(*launcher_action_with_info_result); @@ -137,7 +137,7 @@ Result ServerLoopImpl::Run() { auto response = LauncherResponse::kSuccess; if (!result.ok()) { LOG(ERROR) << "Failed to handle extended action request."; - LOG(ERROR) << result.error().FormatForEnv(); + LOG(ERROR) << result.error(); response = LauncherResponse::kError; } const auto n_written = client->Write(&response, sizeof(response)); @@ -223,8 +223,7 @@ void ServerLoopImpl::HandleActionWithNoData(const LauncherAction action, client->Write(&response, sizeof(response)); std::exit(0); } else { - LOG(ERROR) << "Failed to stop subprocesses:\n" - << stop.error().FormatForEnv(); + LOG(ERROR) << "Failed to stop subprocesses:\n" << stop.error(); auto response = LauncherResponse::kError; client->Write(&response, sizeof(response)); } @@ -239,8 +238,7 @@ void ServerLoopImpl::HandleActionWithNoData(const LauncherAction action, } else { auto response = LauncherResponse::kError; client->Write(&response, sizeof(response)); - LOG(ERROR) << "Failed to stop subprocesses:\n" - << stop.error().FormatForEnv(); + LOG(ERROR) << "Failed to stop subprocesses:\n" << stop.error(); } break; } @@ -263,8 +261,7 @@ void ServerLoopImpl::HandleActionWithNoData(const LauncherAction action, auto stop = process_monitor.StopMonitoredProcesses(); if (!stop.ok()) { - LOG(ERROR) << "Stopping processes failed:\n" - << stop.error().FormatForEnv(); + LOG(ERROR) << "Stopping processes failed:\n" << stop.error(); auto response = LauncherResponse::kError; client->Write(&response, sizeof(response)); break; @@ -288,8 +285,7 @@ void ServerLoopImpl::HandleActionWithNoData(const LauncherAction action, case LauncherAction::kRestart: { auto stop = process_monitor.StopMonitoredProcesses(); if (!stop.ok()) { - LOG(ERROR) << "Stopping processes failed:\n" - << stop.error().FormatForEnv(); + LOG(ERROR) << "Stopping processes failed:\n" << stop.error(); auto response = LauncherResponse::kError; client->Write(&response, sizeof(response)); break; diff --git a/base/cvd/cuttlefish/host/commands/screen_recording_server/main.cpp b/base/cvd/cuttlefish/host/commands/screen_recording_server/main.cpp index 2110bf06754..21dcbbf2181 100644 --- a/base/cvd/cuttlefish/host/commands/screen_recording_server/main.cpp +++ b/base/cvd/cuttlefish/host/commands/screen_recording_server/main.cpp @@ -72,8 +72,7 @@ class ScreenRecordingServiceImpl final successes_res->end()); return Status::OK; } else { - LOG(ERROR) << "Failed to start recording: " - << successes_res.error().FormatForEnv(); + LOG(ERROR) << "Failed to start recording: " << successes_res.error(); reply->mutable_successes()->Add(false); return Status(StatusCode::ABORTED, successes_res.error().FormatForEnv(false)); @@ -89,7 +88,7 @@ class ScreenRecordingServiceImpl final successes.push_back(result.ok()); if (!result.ok()) { LOG(ERROR) << "Failed to communicate with instance " << instance.id() - << ": " << result.error().FormatForEnv(); + << ": " << result.error(); } } return successes; diff --git a/base/cvd/cuttlefish/host/commands/secure_env/oemlock/oemlock.cpp b/base/cvd/cuttlefish/host/commands/secure_env/oemlock/oemlock.cpp index 3fffc74cbd3..df43eaba868 100644 --- a/base/cvd/cuttlefish/host/commands/secure_env/oemlock/oemlock.cpp +++ b/base/cvd/cuttlefish/host/commands/secure_env/oemlock/oemlock.cpp @@ -64,7 +64,7 @@ OemLock::OemLock(secure_env::Storage& storage) : storage_(storage) { auto result = InitializeDefaultState(storage_); if (!result.ok()) { LOG(FATAL) << "Failed to initialize default state for OemLock TEE storage: " - << result.error().FormatForEnv(); + << result.error(); } } diff --git a/base/cvd/cuttlefish/host/commands/secure_env/secure_env_not_windows_main.cpp b/base/cvd/cuttlefish/host/commands/secure_env/secure_env_not_windows_main.cpp index 65d9be4c263..6457f5ae83f 100644 --- a/base/cvd/cuttlefish/host/commands/secure_env/secure_env_not_windows_main.cpp +++ b/base/cvd/cuttlefish/host/commands/secure_env/secure_env_not_windows_main.cpp @@ -127,7 +127,7 @@ std::thread StartKernelEventMonitor(SharedFD kernel_events_fd, return std::thread([kernel_events_fd, &oemlock_lock]() { while (kernel_events_fd->IsOpen()) { auto read_result = monitor::ReadEvent(kernel_events_fd); - CHECK(read_result.ok()) << read_result.error().FormatForEnv(); + CHECK(read_result.ok()) << read_result.error(); CHECK(read_result->has_value()) << "EOF in kernel log monitor"; if ((*read_result)->event == monitor::Event::BootloaderLoaded) { LOG(DEBUG) << "secure_env detected guest reboot, restarting."; diff --git a/base/cvd/cuttlefish/host/commands/secure_env/secure_env_only_oemlock.cpp b/base/cvd/cuttlefish/host/commands/secure_env/secure_env_only_oemlock.cpp index a95e506efe7..b0c54e651a3 100644 --- a/base/cvd/cuttlefish/host/commands/secure_env/secure_env_only_oemlock.cpp +++ b/base/cvd/cuttlefish/host/commands/secure_env/secure_env_only_oemlock.cpp @@ -106,7 +106,7 @@ std::thread StartKernelEventMonitor(SharedFD kernel_events_fd, return std::thread([kernel_events_fd, &oemlock_lock]() { while (kernel_events_fd->IsOpen()) { auto read_result = monitor::ReadEvent(kernel_events_fd); - CHECK(read_result.ok()) << read_result.error().FormatForEnv(); + CHECK(read_result.ok()) << read_result.error(); CHECK(read_result->has_value()) << "EOF in kernel log monitor"; if ((*read_result)->event == monitor::Event::BootloaderLoaded) { LOG(DEBUG) << "secure_env detected guest reboot, restarting."; diff --git a/base/cvd/cuttlefish/host/commands/secure_env/tpm_gatekeeper.cpp b/base/cvd/cuttlefish/host/commands/secure_env/tpm_gatekeeper.cpp index a0eb7527bca..2a635418b9a 100644 --- a/base/cvd/cuttlefish/host/commands/secure_env/tpm_gatekeeper.cpp +++ b/base/cvd/cuttlefish/host/commands/secure_env/tpm_gatekeeper.cpp @@ -182,8 +182,7 @@ bool TpmGatekeeper::GetFailureRecord( secure_env::Storage& storage = secure ? secure_storage_ : insecure_storage_; auto result = GetFailureRecordImpl(storage, uid, secure_user_id, record); if (!result.ok()) { - LOG(ERROR) << "Failed to get failure record: " - << result.error().FormatForEnv(); + LOG(ERROR) << "Failed to get failure record: " << result.error(); } return result.ok(); } @@ -204,8 +203,7 @@ bool TpmGatekeeper::ClearFailureRecord( gatekeeper::failure_record_t record = DefaultRecord(secure_user_id); auto result = WriteFailureRecordImpl(storage, uid, &record); if (!result.ok()) { - LOG(ERROR) << "Failed to clear failure record: " - << result.error().FormatForEnv(); + LOG(ERROR) << "Failed to clear failure record: " << result.error(); } return result.ok(); } @@ -215,8 +213,7 @@ bool TpmGatekeeper::WriteFailureRecord( secure_env::Storage& storage = secure ? secure_storage_ : insecure_storage_; auto result = WriteFailureRecordImpl(storage, uid, record); if (!result.ok()) { - LOG(ERROR) << "Failed to write failure record: " - << result.error().FormatForEnv(); + LOG(ERROR) << "Failed to write failure record: " << result.error(); } return result.ok(); } diff --git a/base/cvd/cuttlefish/host/commands/sensors_simulator/main.cpp b/base/cvd/cuttlefish/host/commands/sensors_simulator/main.cpp index 046aaa5e6da..b84443f1b92 100644 --- a/base/cvd/cuttlefish/host/commands/sensors_simulator/main.cpp +++ b/base/cvd/cuttlefish/host/commands/sensors_simulator/main.cpp @@ -127,7 +127,7 @@ int SensorsSimulatorMain(int argc, char** argv) { while (true) { auto result = ProcessWebrtcRequest(channel, sensors_simulator); if (!result.ok()) { - LOG(ERROR) << result.error().FormatForEnv(); + LOG(ERROR) << result.error(); } } return 0; diff --git a/base/cvd/cuttlefish/host/commands/sensors_simulator/sensors_hal_proxy.cpp b/base/cvd/cuttlefish/host/commands/sensors_simulator/sensors_hal_proxy.cpp index 9b408ff222b..5c2c40c5721 100644 --- a/base/cvd/cuttlefish/host/commands/sensors_simulator/sensors_hal_proxy.cpp +++ b/base/cvd/cuttlefish/host/commands/sensors_simulator/sensors_hal_proxy.cpp @@ -167,7 +167,7 @@ SensorsHalProxy::SensorsHalProxy(SharedFD control_from_guest_fd, host_enabled_sensors); if (!result.ok()) { running_ = false; - LOG(ERROR) << result.error().FormatForEnv(); + LOG(ERROR) << result.error(); } } }); @@ -182,7 +182,7 @@ SensorsHalProxy::SensorsHalProxy(SharedFD control_from_guest_fd, UpdateSensorsHal(sensors_data, data_channel_, host_update_sensors); if (!result.ok()) { running_ = false; - LOG(ERROR) << result.error().FormatForEnv(); + LOG(ERROR) << result.error(); } } std::this_thread::sleep_for(std::chrono::milliseconds(kIntervalMs)); @@ -191,7 +191,7 @@ SensorsHalProxy::SensorsHalProxy(SharedFD control_from_guest_fd, reboot_monitor_thread_ = std::thread([this] { while (kernel_events_fd_->IsOpen()) { auto read_result = monitor::ReadEvent(kernel_events_fd_); - CHECK(read_result.ok()) << read_result.error().FormatForEnv(); + CHECK(read_result.ok()) << read_result.error(); CHECK(read_result->has_value()) << "EOF in kernel log monitor"; if ((*read_result)->event == monitor::Event::BootloaderLoaded) { hal_activated_ = false; diff --git a/base/cvd/cuttlefish/host/commands/snapshot_util_cvd/main.cc b/base/cvd/cuttlefish/host/commands/snapshot_util_cvd/main.cc index 84be299cfb9..9d68adac714 100644 --- a/base/cvd/cuttlefish/host/commands/snapshot_util_cvd/main.cc +++ b/base/cvd/cuttlefish/host/commands/snapshot_util_cvd/main.cc @@ -114,8 +114,7 @@ Result SnapshotCvdMain(std::vector args) { Result result = BroadcastLauncherAction(*config, parsed, extended_action); if (!result.ok()) { - LOG(FATAL) << "RunLauncherAction failed: " - << result.error().FormatForEnv(); + LOG(FATAL) << "RunLauncherAction failed: " << result.error(); } }); @@ -128,7 +127,7 @@ Result SnapshotCvdMain(std::vector args) { Result result = RecursivelyRemoveDirectory(parsed.snapshot_path); if (!result.ok()) { LOG(ERROR) << "Failed to delete incomplete snapshot: " - << result.error().FormatForEnv(); + << result.error(); } }); @@ -159,7 +158,7 @@ int main(int argc, char** argv) { std::vector all_args = cuttlefish::ArgsToVec(argc, argv); auto result = cuttlefish::SnapshotCvdMain(std::move(all_args)); if (!result.ok()) { - LOG(ERROR) << result.error().FormatForEnv(); + LOG(ERROR) << result.error(); return EXIT_FAILURE; } return EXIT_SUCCESS; diff --git a/base/cvd/cuttlefish/host/commands/start/main.cc b/base/cvd/cuttlefish/host/commands/start/main.cc index c2838ec0ea4..623369796f5 100644 --- a/base/cvd/cuttlefish/host/commands/start/main.cc +++ b/base/cvd/cuttlefish/host/commands/start/main.cc @@ -214,7 +214,7 @@ int CvdInternalStartMain(int argc, char** argv) { if (!parse_res.ok()) { LOG(ERROR) << "Error extracting system_image_dir from args: " - << parse_res.error().FormatForEnv(); + << parse_res.error(); return -1; } else if (!image_dir.empty()) { LOG(INFO) << "Using system_image_dir of: " << image_dir; @@ -250,7 +250,7 @@ int CvdInternalStartMain(int argc, char** argv) { auto instance_nums = InstanceNumsCalculator().FromGlobalGflags().Calculate(); if (!instance_nums.ok()) { - LOG(ERROR) << instance_nums.error().FormatForEnv(); + LOG(ERROR) << instance_nums.error(); abort(); } @@ -316,8 +316,7 @@ int CvdInternalStartMain(int argc, char** argv) { for (const auto& instance : config->Instances()) { Result link_res = LinkLogs2InstanceDir(conf_path, *config, instance); if (!link_res.ok()) { - LOG(ERROR) << "Failed to link logs to instance dir: " - << link_res.error().FormatForEnv(); + LOG(ERROR) << "Failed to link logs to instance dir: " << link_res.error(); } SharedFD runner_stdin = SharedFD::Open("/dev/null", O_RDONLY); CHECK(runner_stdin->IsOpen()) << runner_stdin->StrError(); diff --git a/base/cvd/cuttlefish/host/commands/status/main.cc b/base/cvd/cuttlefish/host/commands/status/main.cc index 2ed37c6e32d..9ae0621ded8 100644 --- a/base/cvd/cuttlefish/host/commands/status/main.cc +++ b/base/cvd/cuttlefish/host/commands/status/main.cc @@ -150,13 +150,13 @@ int main(int argc, char** argv) { cuttlefish::Result flag_result = cuttlefish::GetFlagValues(argc, argv); if (!flag_result.ok()) { - LOG(ERROR) << flag_result.error().FormatForEnv(); + LOG(ERROR) << flag_result.error(); return EXIT_FAILURE; } auto result = cuttlefish::CvdStatusMain(flag_result.value()); if (!result.ok()) { - LOG(ERROR) << result.error().FormatForEnv(); + LOG(ERROR) << result.error(); return EXIT_FAILURE; } return EXIT_SUCCESS; diff --git a/base/cvd/cuttlefish/host/commands/stop/main.cc b/base/cvd/cuttlefish/host/commands/stop/main.cc index e1c4fcfec05..5358c4e6ea8 100644 --- a/base/cvd/cuttlefish/host/commands/stop/main.cc +++ b/base/cvd/cuttlefish/host/commands/stop/main.cc @@ -143,7 +143,7 @@ int StopInstance(const CuttlefishConfig& config, const std::int32_t wait_for_launcher) { auto result = CleanStopInstance(instance, wait_for_launcher); if (!result.ok()) { - LOG(ERROR) << "Clean stop failed: " << result.error().FormatForEnv(); + LOG(ERROR) << "Clean stop failed: " << result.error(); return FallBackStop(DirsForInstance(config, instance)); } diff --git a/base/cvd/cuttlefish/host/commands/tombstone_receiver/main.cpp b/base/cvd/cuttlefish/host/commands/tombstone_receiver/main.cpp index 010f102c081..6f1aee1bcb8 100644 --- a/base/cvd/cuttlefish/host/commands/tombstone_receiver/main.cpp +++ b/base/cvd/cuttlefish/host/commands/tombstone_receiver/main.cpp @@ -73,7 +73,7 @@ int TombstoneReceiverMain(int argc, char** argv) { ArgsToVec(argc - 1, argv + 1); // Skip argv[0] auto parse_res = ConsumeFlags(flags, args); CHECK(parse_res.ok()) << "Could not process command line flags. " - << parse_res.error().FormatForEnv(); + << parse_res.error(); CHECK(server_fd->IsOpen()) << "Did not receive a server fd"; diff --git a/base/cvd/cuttlefish/host/frontend/webrtc/connection_observer.cpp b/base/cvd/cuttlefish/host/frontend/webrtc/connection_observer.cpp index 3bf1dae4a1e..b8498b74928 100644 --- a/base/cvd/cuttlefish/host/frontend/webrtc/connection_observer.cpp +++ b/base/cvd/cuttlefish/host/frontend/webrtc/connection_observer.cpp @@ -353,7 +353,7 @@ class ConnectionObserverImpl : public webrtc_streaming::ConnectionObserver { void OnDisplayAddMsg(const Json::Value &msg) override { auto result = HandleDisplayAddMessage(msg); if (!result.ok()) { - LOG(ERROR) << result.error().FormatForEnv(); + LOG(ERROR) << result.error(); } } @@ -382,7 +382,7 @@ class ConnectionObserverImpl : public webrtc_streaming::ConnectionObserver { void OnDisplayRemoveMsg(const Json::Value &msg) override { auto result = HandleDisplayRemoveMessage(msg); if (!result.ok()) { - LOG(ERROR) << result.error().FormatForEnv(); + LOG(ERROR) << result.error(); } } diff --git a/base/cvd/cuttlefish/host/frontend/webrtc/gpx_locations_handler.cpp b/base/cvd/cuttlefish/host/frontend/webrtc/gpx_locations_handler.cpp index e213329850e..3f03c9aa099 100644 --- a/base/cvd/cuttlefish/host/frontend/webrtc/gpx_locations_handler.cpp +++ b/base/cvd/cuttlefish/host/frontend/webrtc/gpx_locations_handler.cpp @@ -59,7 +59,7 @@ void GpxLocationsHandler::HandleMessage(const uint8_t *msg, size_t len) { Result reply = gpsclient.SendGpsLocations(1000, coordinates); if (!reply.ok()) { - LOG(ERROR) << reply.error().FormatForEnv(); + LOG(ERROR) << reply.error(); } } diff --git a/base/cvd/cuttlefish/host/frontend/webrtc/kernel_log_events_handler.cpp b/base/cvd/cuttlefish/host/frontend/webrtc/kernel_log_events_handler.cpp index e1bf08b315c..bf71f131022 100644 --- a/base/cvd/cuttlefish/host/frontend/webrtc/kernel_log_events_handler.cpp +++ b/base/cvd/cuttlefish/host/frontend/webrtc/kernel_log_events_handler.cpp @@ -66,7 +66,7 @@ void KernelLogEventsHandler::ReadLoop() { monitor::ReadEvent(kernel_log_fd_); if (!read_result.ok()) { LOG(ERROR) << "Failed to read kernel log event: " - << read_result.error().FormatForEnv(); + << read_result.error(); break; } else if (!(*read_result)) { LOG(ERROR) << "EOF from kernel_log_monitor"; diff --git a/base/cvd/cuttlefish/host/frontend/webrtc/kml_locations_handler.cpp b/base/cvd/cuttlefish/host/frontend/webrtc/kml_locations_handler.cpp index 59765059ed6..cf1cd966f50 100644 --- a/base/cvd/cuttlefish/host/frontend/webrtc/kml_locations_handler.cpp +++ b/base/cvd/cuttlefish/host/frontend/webrtc/kml_locations_handler.cpp @@ -59,7 +59,7 @@ void KmlLocationsHandler::HandleMessage(const uint8_t *msg, size_t len) { Result reply = gpsclient.SendGpsLocations(1000, coordinates); if (!reply.ok()) { - LOG(ERROR) << reply.error().FormatForEnv(); + LOG(ERROR) << reply.error(); } } diff --git a/base/cvd/cuttlefish/host/frontend/webrtc/libcommon/connection_controller.cpp b/base/cvd/cuttlefish/host/frontend/webrtc/libcommon/connection_controller.cpp index 58a8798dd4d..d5aa675c919 100644 --- a/base/cvd/cuttlefish/host/frontend/webrtc/libcommon/connection_controller.cpp +++ b/base/cvd/cuttlefish/host/frontend/webrtc/libcommon/connection_controller.cpp @@ -43,7 +43,7 @@ class CreateSessionDescriptionObserverIntermediate void OnSuccess(webrtc::SessionDescriptionInterface* desc) override { auto res = controller_.OnCreateSDPSuccess(desc); if (!res.ok()) { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); } } void OnFailure(webrtc::RTCError error) override { @@ -125,7 +125,7 @@ void ConnectionController::FailConnection(const std::string& message) { reply["error"] = message; auto res = sig_handler_.SendMessage(reply); if (!res.ok()) { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); } observer_.OnConnectionStateChange(CF_ERR(message)); } @@ -276,7 +276,7 @@ ConnectionController::ThisAsSetRemoteSDPObserver() { void ConnectionController::HandleSignalingMessage(const Json::Value& msg) { auto result = HandleSignalingMessageInner(msg); if (!result.ok()) { - LOG(ERROR) << result.error().FormatForEnv(); + LOG(ERROR) << result.error(); FailConnection(result.error().Message()); } } @@ -418,7 +418,7 @@ void ConnectionController::OnIceCandidate( auto res = sig_handler_.SendMessage(reply); if (!res.ok()) { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); } } diff --git a/base/cvd/cuttlefish/host/frontend/webrtc/libdevice/client_handler.cpp b/base/cvd/cuttlefish/host/frontend/webrtc/libdevice/client_handler.cpp index 27107815aed..a60e1134e86 100644 --- a/base/cvd/cuttlefish/host/frontend/webrtc/libdevice/client_handler.cpp +++ b/base/cvd/cuttlefish/host/frontend/webrtc/libdevice/client_handler.cpp @@ -226,7 +226,7 @@ void ClientHandler::Close() { void ClientHandler::OnConnectionStateChange( Result new_state) { if (!new_state.ok()) { - LOG(ERROR) << "Connection error: " << new_state.error().FormatForEnv(); + LOG(ERROR) << "Connection error: " << new_state.error(); Close(); return; } diff --git a/base/cvd/cuttlefish/host/frontend/webrtc/libdevice/data_channels.cpp b/base/cvd/cuttlefish/host/frontend/webrtc/libdevice/data_channels.cpp index 80cc2be3c5e..4b586eae29c 100644 --- a/base/cvd/cuttlefish/host/frontend/webrtc/libdevice/data_channels.cpp +++ b/base/cvd/cuttlefish/host/frontend/webrtc/libdevice/data_channels.cpp @@ -442,7 +442,7 @@ void DataChannelHandler::OnMessage(const webrtc::DataBuffer &msg) { } auto res = OnMessageInner(msg); if (!res.ok()) { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); } } diff --git a/base/cvd/cuttlefish/host/frontend/webrtc/libdevice/streamer.cpp b/base/cvd/cuttlefish/host/frontend/webrtc/libdevice/streamer.cpp index c04b73f096a..da040e4b19c 100644 --- a/base/cvd/cuttlefish/host/frontend/webrtc/libdevice/streamer.cpp +++ b/base/cvd/cuttlefish/host/frontend/webrtc/libdevice/streamer.cpp @@ -205,21 +205,21 @@ std::unique_ptr Streamer::Create( auto network_thread_result = CreateAndStartThread("network-thread"); if (!network_thread_result.ok()) { - LOG(ERROR) << network_thread_result.error().FormatForEnv(); + LOG(ERROR) << network_thread_result.error(); return nullptr; } impl->network_thread_ = std::move(*network_thread_result); auto worker_thread_result = CreateAndStartThread("worker-thread"); if (!worker_thread_result.ok()) { - LOG(ERROR) << worker_thread_result.error().FormatForEnv(); + LOG(ERROR) << worker_thread_result.error(); return nullptr; } impl->worker_thread_ = std::move(*worker_thread_result); auto signal_thread_result = CreateAndStartThread("signal-thread"); if (!signal_thread_result.ok()) { - LOG(ERROR) << signal_thread_result.error().FormatForEnv(); + LOG(ERROR) << signal_thread_result.error(); return nullptr; } impl->signal_thread_ = std::move(*signal_thread_result); @@ -233,7 +233,7 @@ std::unique_ptr Streamer::Create( impl->signal_thread_.get(), impl->audio_device_module_->device_module()); if (!result.ok()) { - LOG(ERROR) << result.error().FormatForEnv(); + LOG(ERROR) << result.error(); return nullptr; } impl->peer_connection_factory_ = *result; @@ -547,7 +547,7 @@ void Streamer::Impl::HandleConfigMessage(const Json::Value& server_message) { auto result = ParseIceServersMessage(server_message); if (!result.ok()) { LOG(WARNING) << "Failed to parse ice servers message from server: " - << result.error().FormatForEnv(); + << result.error(); } operator_config_.servers = *result; } diff --git a/base/cvd/cuttlefish/host/frontend/webrtc/location_handler.cpp b/base/cvd/cuttlefish/host/frontend/webrtc/location_handler.cpp index ea2f1438d92..f7aab6f8282 100644 --- a/base/cvd/cuttlefish/host/frontend/webrtc/location_handler.cpp +++ b/base/cvd/cuttlefish/host/frontend/webrtc/location_handler.cpp @@ -56,7 +56,7 @@ void LocationHandler::HandleMessage(const float longitude, Result reply = gpsclient.SendGpsLocations(1000, coordinates); if (!reply.ok()) { - LOG(ERROR) << reply.error().FormatForEnv(); + LOG(ERROR) << reply.error(); } } diff --git a/base/cvd/cuttlefish/host/frontend/webrtc/sensors_handler.cpp b/base/cvd/cuttlefish/host/frontend/webrtc/sensors_handler.cpp index 8b32e5594e8..612f225b4d2 100644 --- a/base/cvd/cuttlefish/host/frontend/webrtc/sensors_handler.cpp +++ b/base/cvd/cuttlefish/host/frontend/webrtc/sensors_handler.cpp @@ -34,8 +34,7 @@ SensorsHandler::SensorsHandler(SharedFD sensors_fd) : channel_(transport::SharedFdChannel(sensors_fd, sensors_fd)) { auto refresh_result = RefreshSensors(0, 0, 0); if (!refresh_result.ok()) { - LOG(ERROR) << "Failed to refresh sensors: " - << refresh_result.error().FormatForEnv(); + LOG(ERROR) << "Failed to refresh sensors: " << refresh_result.error(); } } @@ -81,8 +80,7 @@ Result SensorsHandler::GetSensorsData() { void SensorsHandler::HandleMessage(const double x, const double y, const double z) { auto refresh_result = RefreshSensors(x, y, z); if (!refresh_result.ok()) { - LOG(ERROR) << "Failed to refresh sensors: " - << refresh_result.error().FormatForEnv(); + LOG(ERROR) << "Failed to refresh sensors: " << refresh_result.error(); return; } UpdateSensorsUi(); @@ -98,8 +96,7 @@ int SensorsHandler::Subscribe(std::function send_t // Send device's initial state to the new client. auto result = GetSensorsData(); if (!result.ok()) { - LOG(ERROR) << "Failed to get sensors data: " - << result.error().FormatForEnv(); + LOG(ERROR) << "Failed to get sensors data: " << result.error(); return subscriber_id; } auto new_sensors_data = std::move(result.value()); @@ -118,8 +115,7 @@ void SensorsHandler::UnSubscribe(int subscriber_id) { void SensorsHandler::UpdateSensorsUi() { auto result = GetSensorsData(); if (!result.ok()) { - LOG(ERROR) << "Failed to get sensors data: " - << result.error().FormatForEnv(); + LOG(ERROR) << "Failed to get sensors data: " << result.error(); return; } auto new_sensors_data = std::move(result.value()); diff --git a/base/cvd/cuttlefish/host/libs/config/custom_actions.cpp b/base/cvd/cuttlefish/host/libs/config/custom_actions.cpp index 4aecbb99243..da26ec950d6 100644 --- a/base/cvd/cuttlefish/host/libs/config/custom_actions.cpp +++ b/base/cvd/cuttlefish/host/libs/config/custom_actions.cpp @@ -182,8 +182,7 @@ std::string DefaultCustomActionConfig() { if (DirectoryExists(custom_action_config_dir)) { auto directory_contents_result = DirectoryContents(custom_action_config_dir); - CHECK(directory_contents_result.ok()) - << directory_contents_result.error().FormatForEnv(); + CHECK(directory_contents_result.ok()) << directory_contents_result.error(); auto custom_action_configs = std::move(*directory_contents_result); if (custom_action_configs.size() > 1) { LOG(ERROR) << "Expected at most one custom action config in " diff --git a/base/cvd/cuttlefish/host/libs/config/data_image.cpp b/base/cvd/cuttlefish/host/libs/config/data_image.cpp index 91ac6bf3df7..bfb63a021c3 100644 --- a/base/cvd/cuttlefish/host/libs/config/data_image.cpp +++ b/base/cvd/cuttlefish/host/libs/config/data_image.cpp @@ -108,8 +108,7 @@ std::string GetFsType(const std::string& path) { Result blkid_out = RunAndCaptureStdout(std::move(command)); if (!blkid_out.ok()) { - LOG(ERROR) << "`blkid '" << path - << "'` failed: " << blkid_out.error().FormatForEnv(); + LOG(ERROR) << "`blkid '" << path << "'` failed: " << blkid_out.error(); return ""; } @@ -218,7 +217,7 @@ Result InitializeDataImage( return {}; case DataImageAction::kCreateBlankImage: { if (Result res = RemoveFile(instance.new_data_image()); !res.ok()) { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); } CF_EXPECT(instance.blank_data_image_mb() != 0, "Expected `-blank_data_image_mb` to be set for " diff --git a/base/cvd/cuttlefish/host/libs/config/host_tools_version.cpp b/base/cvd/cuttlefish/host/libs/config/host_tools_version.cpp index ea319818532..c134931bfc0 100644 --- a/base/cvd/cuttlefish/host/libs/config/host_tools_version.cpp +++ b/base/cvd/cuttlefish/host/libs/config/host_tools_version.cpp @@ -52,7 +52,7 @@ static std::map DirectoryCrc(const std::string& path) { return {}; } auto files_result = DirectoryContents(full_path); - CHECK(files_result.ok()) << files_result.error().FormatForEnv(); + CHECK(files_result.ok()) << files_result.error(); std::vector files = std::move(*files_result); std::vector> calculations; calculations.reserve(files.size()); diff --git a/base/cvd/cuttlefish/host/libs/confui/session.cc b/base/cvd/cuttlefish/host/libs/confui/session.cc index c88c5fb4d07..da5e85e36c2 100644 --- a/base/cvd/cuttlefish/host/libs/confui/session.cc +++ b/base/cvd/cuttlefish/host/libs/confui/session.cc @@ -56,7 +56,7 @@ bool Session::RenderDialog() { auto result = renderer_.RenderDialog(display_num_, prompt_text_, locale_, ui_options_); if (!result.ok()) { - LOG(ERROR) << result.error().FormatForEnv(); + LOG(ERROR) << result.error(); return false; } return true; diff --git a/base/cvd/cuttlefish/host/libs/metrics/metrics_orchestration.cc b/base/cvd/cuttlefish/host/libs/metrics/metrics_orchestration.cc index 0e583bd9850..ccb91fc83ad 100644 --- a/base/cvd/cuttlefish/host/libs/metrics/metrics_orchestration.cc +++ b/base/cvd/cuttlefish/host/libs/metrics/metrics_orchestration.cc @@ -150,7 +150,7 @@ void RunMetrics(const MetricsPaths& metrics_paths, EventType event_type) { if (!gather_result.ok()) { LOG(DEBUG) << fmt::format( "Failed to gather all metrics data for {}. Error: {}", - EventTypeString(event_type), gather_result.error().FormatForEnv()); + EventTypeString(event_type), gather_result.error()); return; } @@ -159,7 +159,7 @@ void RunMetrics(const MetricsPaths& metrics_paths, EventType event_type) { if (!output_result.ok()) { LOG(DEBUG) << fmt::format("Failed to output metrics for {}. Error: {}", EventTypeString(event_type), - output_result.error().FormatForEnv()); + output_result.error()); } } @@ -171,7 +171,7 @@ void GatherVmInstantiationMetrics(const LocalInstanceGroup& instance_group) { SetUpMetrics(metrics_paths.metrics_directory); if (!metrics_setup_result.ok()) { LOG(DEBUG) << fmt::format("Failed to initialize metrics. Error: {}", - metrics_setup_result.error().FormatForEnv()); + metrics_setup_result.error()); return; } if (kEnableCvdMetrics) { diff --git a/base/cvd/cuttlefish/host/libs/process_monitor/process_monitor.cc b/base/cvd/cuttlefish/host/libs/process_monitor/process_monitor.cc index b7971c2b3e6..5c0231aebb7 100644 --- a/base/cvd/cuttlefish/host/libs/process_monitor/process_monitor.cc +++ b/base/cvd/cuttlefish/host/libs/process_monitor/process_monitor.cc @@ -408,8 +408,7 @@ Result ProcessMonitor::StartAndMonitorProcesses() { child_channel_ = transport::SharedFdChannel(child_sock, child_sock); Result monitor_result = MonitorRoutine(); if (!monitor_result.ok()) { - LOG(ERROR) << "Monitoring processes failed:\n" - << monitor_result.error().FormatForEnv(); + LOG(ERROR) << "Monitoring processes failed:\n" << monitor_result.error(); } pipe_write->Close(); std::exit(monitor_result.ok() ? 0 : 1); diff --git a/base/cvd/cuttlefish/host/libs/screen_connector/composition_manager.cpp b/base/cvd/cuttlefish/host/libs/screen_connector/composition_manager.cpp index b78e9174064..2f2f68c9ec7 100644 --- a/base/cvd/cuttlefish/host/libs/screen_connector/composition_manager.cpp +++ b/base/cvd/cuttlefish/host/libs/screen_connector/composition_manager.cpp @@ -181,7 +181,7 @@ void CompositionManager::OnDisplayCreated(const DisplayCreatedEvent& e) { cluster_index_, e.display_number, e.display_width, e.display_height); if (!result.ok()) { - LOG(FATAL) << "OnDisplayCreated failed: " << result.error().FormatForEnv(); + LOG(FATAL) << "OnDisplayCreated failed: " << result.error(); } } diff --git a/base/cvd/cuttlefish/host/libs/vm_manager/crosvm_display_controller.cpp b/base/cvd/cuttlefish/host/libs/vm_manager/crosvm_display_controller.cpp index 145dae6bc68..dd7ac27f25f 100644 --- a/base/cvd/cuttlefish/host/libs/vm_manager/crosvm_display_controller.cpp +++ b/base/cvd/cuttlefish/host/libs/vm_manager/crosvm_display_controller.cpp @@ -109,8 +109,7 @@ Result CrosvmDisplayController::RunCrosvmDisplayCommand( } return 0; } else { - LOG(ERROR) << "Failed to run crosvm display command:\n" - << res.error().FormatForEnv(); + LOG(ERROR) << "Failed to run crosvm display command:\n" << res.error(); return 0; } } diff --git a/base/cvd/cuttlefish/host/libs/web/caching_build_api.cpp b/base/cvd/cuttlefish/host/libs/web/caching_build_api.cpp index 5aa499557e2..088b4673006 100644 --- a/base/cvd/cuttlefish/host/libs/web/caching_build_api.cpp +++ b/base/cvd/cuttlefish/host/libs/web/caching_build_api.cpp @@ -73,7 +73,7 @@ bool EnsureCacheDirectory(const std::string& cache_base_path) { return true; } LOG(WARNING) << "Failed to create cache directory \"" << cache_base_path - << "\" with error: " << result.error().FormatForEnv(); + << "\" with error: " << result.error(); LOG(WARNING) << "Caching disabled"; return false; } diff --git a/base/cvd/cuttlefish/host/libs/web/cas/cas_downloader.cpp b/base/cvd/cuttlefish/host/libs/web/cas/cas_downloader.cpp index 2d46b26709f..f7d6d5c26eb 100644 --- a/base/cvd/cuttlefish/host/libs/web/cas/cas_downloader.cpp +++ b/base/cvd/cuttlefish/host/libs/web/cas/cas_downloader.cpp @@ -295,7 +295,7 @@ Result> CasDownloader::Create( // Ensure callers and logs clearly indicate that CAS downloading is // disabled and why, using the same environment-aware formatting that // test helpers use. - LOG(INFO) << "CAS downloading disabled: " << result.error().FormatForEnv(); + LOG(INFO) << "CAS downloading disabled: " << result.error(); return result; } @@ -451,7 +451,7 @@ Result CasDownloader::GetCasIdentifier( std::string digests_filepath = CF_EXPECT(digests_fetcher(digests_filename)); Json::Value cas_digests = CF_EXPECT(ParseJson(ReadFile(digests_filepath))); if (Result res = RemoveFile(digests_filepath); !res.ok()) { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); } std::vector mandatory_keys{ "cas_instance", diff --git a/base/cvd/cuttlefish/host/libs/web/cas/cas_downloader_test.cpp b/base/cvd/cuttlefish/host/libs/web/cas/cas_downloader_test.cpp index e2fa5cdfdc9..35ce0e2e187 100644 --- a/base/cvd/cuttlefish/host/libs/web/cas/cas_downloader_test.cpp +++ b/base/cvd/cuttlefish/host/libs/web/cas/cas_downloader_test.cpp @@ -227,7 +227,7 @@ fi void SetUp() override { Result result = CreateTestDirs(); if (!result.ok()) { - FAIL() << result.error().FormatForEnv(); + FAIL() << result.error(); } } diff --git a/base/cvd/cuttlefish/host/libs/web/credential_source.cc b/base/cvd/cuttlefish/host/libs/web/credential_source.cc index 534c4b8543d..1577d30d138 100644 --- a/base/cvd/cuttlefish/host/libs/web/credential_source.cc +++ b/base/cvd/cuttlefish/host/libs/web/credential_source.cc @@ -170,7 +170,7 @@ std::unique_ptr TryParseServiceAccount( http_client, content, kAndroidBuildApiScope); if (!result.ok()) { LOG(DEBUG) << "Failed to load service account json file: \n" - << result.error().FormatForEnv(); + << result.error(); return {}; } return std::move(*result); @@ -192,8 +192,7 @@ Result> GetCredentialSourceLegacy( LOG(DEBUG) << "Loaded credentials from '" << oauth_filepath << "'"; } else { LOG(ERROR) << "Failed to load oauth credentials from \"" - << oauth_filepath - << "\":" << attempt_load.error().FormatForEnv(); + << oauth_filepath << "\":" << attempt_load.error(); } } else { LOG(INFO) << "\"" << oauth_filepath diff --git a/base/cvd/cuttlefish/host/libs/web/http_client/http_file.cc b/base/cvd/cuttlefish/host/libs/web/http_client/http_file.cc index 673d6976cfa..ea500d1976b 100644 --- a/base/cvd/cuttlefish/host/libs/web/http_client/http_file.cc +++ b/base/cvd/cuttlefish/host/libs/web/http_client/http_file.cc @@ -50,14 +50,14 @@ Result> HttpGetToFile( if (data == nullptr) { if (!temp_path.empty()) { if (Result res = RemoveFile(temp_path); !res.ok()) { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); } } total_dl = 0; last_log = 0; Result> res = SharedFD::Mkostemp(path); if (!res.ok()) { - LOG(ERROR) << "Can't make temp file: " << res.error().FormatForEnv(); + LOG(ERROR) << "Can't make temp file: " << res.error(); return false; } temp_path = res->second; diff --git a/base/cvd/cuttlefish/host/libs/web/http_client/http_json.cc b/base/cvd/cuttlefish/host/libs/web/http_client/http_json.cc index e636b6102d3..253172038f0 100644 --- a/base/cvd/cuttlefish/host/libs/web/http_client/http_json.cc +++ b/base/cvd/cuttlefish/host/libs/web/http_client/http_json.cc @@ -35,7 +35,7 @@ HttpResponse Parse(HttpResponse response) { Result result = ParseJson(response.data); if (!result.ok()) { Json::Value error_json; - LOG(ERROR) << "Could not parse json: " << result.error().FormatForEnv(); + LOG(ERROR) << "Could not parse json: " << result.error(); error_json["error"] = "Failed to parse json: " + result.error().Message(); error_json["response"] = response.data; return HttpResponse{.data = error_json, diff --git a/base/cvd/cuttlefish/host/libs/zip/cached_zip_source.cc b/base/cvd/cuttlefish/host/libs/zip/cached_zip_source.cc index 91e82f7e1e7..461d5793cf9 100644 --- a/base/cvd/cuttlefish/host/libs/zip/cached_zip_source.cc +++ b/base/cvd/cuttlefish/host/libs/zip/cached_zip_source.cc @@ -51,7 +51,7 @@ class CachedZipSourceCallbacks : public SeekableZipSourceCallback { int64_t Read(char* data, uint64_t len) override { LOG(VERBOSE) << "Reading " << len; if (Result res = source_.Seek(offset_); !res.ok()) { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); return -1; } Result res = source_.Read(data, len); @@ -59,7 +59,7 @@ class CachedZipSourceCallbacks : public SeekableZipSourceCallback { offset_ += *res; return *res; } else { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); return -1; } } diff --git a/base/cvd/cuttlefish/host/libs/zip/lazily_loaded_file.cc b/base/cvd/cuttlefish/host/libs/zip/lazily_loaded_file.cc index cc94ddf5609..6f4fc2d4b2a 100644 --- a/base/cvd/cuttlefish/host/libs/zip/lazily_loaded_file.cc +++ b/base/cvd/cuttlefish/host/libs/zip/lazily_loaded_file.cc @@ -90,7 +90,7 @@ LazilyLoadedFile::~LazilyLoadedFile() { } Result res = impl_->WriteMetadata(); if (!res.ok()) { - LOG(WARNING) << "fragment update failure: " << res.error().FormatForEnv(); + LOG(WARNING) << "fragment update failure: " << res.error(); } } @@ -128,7 +128,7 @@ Result LazilyLoadedFile::Impl::ReadMetadata() { if (parsed_res.ok()) { already_downloaded_ = std::move(*parsed_res); } else { - LOG(WARNING) << "Invalid fragments: " << parsed_res.error().FormatForEnv(); + LOG(WARNING) << "Invalid fragments: " << parsed_res.error(); } return {}; diff --git a/base/cvd/cuttlefish/host/libs/zip/remote_zip.cc b/base/cvd/cuttlefish/host/libs/zip/remote_zip.cc index f937f0b8259..27ca3fdfdd2 100644 --- a/base/cvd/cuttlefish/host/libs/zip/remote_zip.cc +++ b/base/cvd/cuttlefish/host/libs/zip/remote_zip.cc @@ -81,7 +81,7 @@ class RemoteZip : public SeekableZipSourceCallback { http_client_.DownloadToCallback(request, cb); if (!res.ok() || !res->HttpSuccess() || already_read != zip_len) { if (!res.ok()) { - LOG(ERROR) << res.error().FormatForEnv(); + LOG(ERROR) << res.error(); } else if (!res->HttpSuccess()) { LOG(ERROR) << "HTTP code: " << res->http_code; } else { diff --git a/base/cvd/cuttlefish/result/error_type.cc b/base/cvd/cuttlefish/result/error_type.cc index ed6ce7acfee..5540481b637 100644 --- a/base/cvd/cuttlefish/result/error_type.cc +++ b/base/cvd/cuttlefish/result/error_type.cc @@ -16,6 +16,7 @@ #include "cuttlefish/result/error_type.h" #include +#include #include #include #include @@ -210,6 +211,10 @@ std::string ResultErrorFormat(bool color) { return "{:" + fmt_str + "}"; } +std::ostream& operator<<(std::ostream& out, const StackTraceError& error) { + return out << error.FormatForEnv(); +} + } // namespace cuttlefish fmt::format_context::iterator diff --git a/base/cvd/cuttlefish/result/error_type.h b/base/cvd/cuttlefish/result/error_type.h index 3cfe670294b..c8bc601eeb2 100644 --- a/base/cvd/cuttlefish/result/error_type.h +++ b/base/cvd/cuttlefish/result/error_type.h @@ -211,6 +211,8 @@ inline StackTraceEntry::operator android::base::expected