diff --git a/src/phone_number.rs b/src/phone_number.rs index 1139520..8907324 100644 --- a/src/phone_number.rs +++ b/src/phone_number.rs @@ -236,8 +236,12 @@ impl<'a> Country<'a> { self.0.code.value() } - pub fn id(&self) -> Option { - self.0.metadata(&DATABASE).and_then(|m| m.id().parse().ok()) + pub fn id(&self) -> Result, crate::error::Parse> { + self.0 + .metadata(&DATABASE) + .map(|m| m.id().parse()) + .transpose() + .map_err(|_e| crate::error::Parse::InvalidCountryCode) } }