Skip to content

Commit be45aa0

Browse files
authored
Make manifest address parsing error more descriptive (diem#75)
1 parent aab456f commit be45aa0

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

language/move-core/types/src/account_address.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,11 @@ pub struct AccountAddressParseError;
267267

268268
impl fmt::Display for AccountAddressParseError {
269269
fn fmt(&self, f: &mut fmt::Formatter) -> std::fmt::Result {
270-
write!(f, "Unable to parse AccountAddress")
270+
write!(
271+
f,
272+
"Unable to parse AccountAddress (must be hex string of length {})",
273+
AccountAddress::LENGTH
274+
)
271275
}
272276
}
273277

language/tools/move-package/src/source_package/manifest_parser.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,10 @@ pub fn parse_addresses(tval: TV) -> Result<PM::AddressDeclarations> {
213213
} else if addresses
214214
.insert(
215215
ident,
216-
Some(parse_address_literal(entry_str).context("Invalid address")?),
216+
Some(parse_address_literal(entry_str).context(format!(
217+
"Invalid address '{}' encountered.",
218+
entry_str
219+
))?),
217220
)
218221
.is_some()
219222
{
@@ -251,7 +254,10 @@ pub fn parse_dev_addresses(tval: TV) -> Result<PM::DevAddressDeclarations> {
251254
} else if addresses
252255
.insert(
253256
ident,
254-
parse_address_literal(entry_str).context("Invalid address")?,
257+
parse_address_literal(entry_str).context(format!(
258+
"Invalid address '{}' encountered.",
259+
entry_str
260+
))?,
255261
)
256262
.is_some()
257263
{

0 commit comments

Comments
 (0)