Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cli] Replace unwraps with better error handling #15061

Merged
merged 1 commit into from
Oct 23, 2024
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: 1 addition & 0 deletions crates/aptos/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
All notable changes to the Aptos CLI will be captured in this file. This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and the format set out by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## Unreleased
- [`Fix`] Remove unwraps to make outputs go through regular error handling

## [4.2.5] - 2024/10/23
- Bump to resolve issue with release version inconsistency.
Expand Down
2 changes: 1 addition & 1 deletion crates/aptos/src/move_tool/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl FmtCommand {
} else {
None
};
let package_path = dir_default_to_current(package_opt.clone()).unwrap();
let package_path = dir_default_to_current(package_opt.clone())?;
let root_res = SourcePackageLayout::try_find_root(&package_path.clone());
if let Ok(root_package_path) = root_res {
let mut path_vec = vec![];
Expand Down
23 changes: 8 additions & 15 deletions crates/aptos/src/move_tool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -784,8 +784,7 @@ impl TryInto<PackagePublicationData> for &PublishPackage {
type Error = CliError;

fn try_into(self) -> Result<PackagePublicationData, Self::Error> {
let package =
build_package_options(&self.move_options, &self.included_artifacts_args).unwrap();
let package = build_package_options(&self.move_options, &self.included_artifacts_args)?;

let package_publication_data =
create_package_publication_data(package, PublishType::AccountDeploy, None)?;
Expand Down Expand Up @@ -815,8 +814,7 @@ impl AsyncTryInto<ChunkedPublishPayloads> for &PublishPackage {
type Error = CliError;

async fn async_try_into(self) -> Result<ChunkedPublishPayloads, Self::Error> {
let package =
build_package_options(&self.move_options, &self.included_artifacts_args).unwrap();
let package = build_package_options(&self.move_options, &self.included_artifacts_args)?;

let chunked_publish_payloads =
create_chunked_publish_payloads(package, PublishType::AccountDeploy, None)?;
Expand Down Expand Up @@ -1146,8 +1144,7 @@ impl CliCommand<TransactionSummary> for CreateObjectAndPublishPackage {
let mock_object_address = AccountAddress::from_hex_literal("0xcafe").unwrap();
self.move_options
.add_named_address(self.address_name.clone(), mock_object_address.to_string());
let package =
build_package_options(&self.move_options, &self.included_artifacts_args).unwrap();
let package = build_package_options(&self.move_options, &self.included_artifacts_args)?;
let mock_payloads =
create_chunked_publish_payloads(package, PublishType::AccountDeploy, None)?
.payloads;
Expand All @@ -1162,8 +1159,7 @@ impl CliCommand<TransactionSummary> for CreateObjectAndPublishPackage {
self.move_options
.add_named_address(self.address_name, object_address.to_string());

let package =
build_package_options(&self.move_options, &self.included_artifacts_args).unwrap();
let package = build_package_options(&self.move_options, &self.included_artifacts_args)?;
let message = format!(
"Do you want to publish this package at object address {}",
object_address
Expand Down Expand Up @@ -1246,7 +1242,7 @@ impl CliCommand<TransactionSummary> for UpgradeObjectPackage {

async fn execute(self) -> CliTypedResult<TransactionSummary> {
let built_package =
build_package_options(&self.move_options, &self.included_artifacts_args).unwrap();
build_package_options(&self.move_options, &self.included_artifacts_args)?;
let url = self
.txn_options
.rest_options
Expand Down Expand Up @@ -1357,8 +1353,7 @@ impl CliCommand<TransactionSummary> for DeployObjectCode {
let mock_object_address = AccountAddress::from_hex_literal("0xcafe").unwrap();
self.move_options
.add_named_address(self.address_name.clone(), mock_object_address.to_string());
let package =
build_package_options(&self.move_options, &self.included_artifacts_args).unwrap();
let package = build_package_options(&self.move_options, &self.included_artifacts_args)?;
let mock_payloads =
create_chunked_publish_payloads(package, PublishType::AccountDeploy, None)?
.payloads;
Expand All @@ -1373,8 +1368,7 @@ impl CliCommand<TransactionSummary> for DeployObjectCode {
self.move_options
.add_named_address(self.address_name, object_address.to_string());

let package =
build_package_options(&self.move_options, &self.included_artifacts_args).unwrap();
let package = build_package_options(&self.move_options, &self.included_artifacts_args)?;
let message = format!(
"Do you want to deploy this package at object address {}",
object_address
Expand Down Expand Up @@ -1463,8 +1457,7 @@ impl CliCommand<TransactionSummary> for UpgradeCodeObject {
self.move_options
.add_named_address(self.address_name, self.object_address.to_string());

let package =
build_package_options(&self.move_options, &self.included_artifacts_args).unwrap();
let package = build_package_options(&self.move_options, &self.included_artifacts_args)?;
let url = self
.txn_options
.rest_options
Expand Down
Loading