pub enum ParseError {
InvalidCountryCode,
NotANumber(NotANumberError),
TooShortAfterIdd,
TooShortNsn,
TooLongNsn,
}Expand description
Represents the possible errors that can occur when parsing a phone number string. This is a public-facing error enum.
Variants§
InvalidCountryCode
Invalid country code.
This error occurs if the number begins with a + but is followed by an
invalid or unrecognized country calling code.
NotANumber(NotANumberError)
The string is not a number.
The input string contains invalid characters or does not conform to a recognizable
phone number format. This variant wraps a NotANumberError for more detail.
TooShortAfterIdd
The number is too short after the International Direct Dialing (IDD) code. After stripping a valid IDD prefix, the remaining part of the number is too short to be a valid national number.
TooShortNsn
The National Significant Number (NSN) is too short. The number, after stripping the country code and any carrier codes, is shorter than any possible valid number for that region.
TooLongNsn
The National Significant Number (NSN) is too long. The number, after stripping the country code, is longer than any possible valid number for that region.
Trait Implementations§
Source§impl Debug for ParseError
impl Debug for ParseError
Source§impl Display for ParseError
impl Display for ParseError
Source§impl Error for ParseError
impl Error for ParseError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
Source§impl From<ExtractNumberError> for ParseError
impl From<ExtractNumberError> for ParseError
Source§fn from(value: ExtractNumberError) -> Self
fn from(value: ExtractNumberError) -> Self
Converts a low-level ExtractNumberError into a public-facing ParseError.
This simplifies the error API by nesting specific errors within more general ones.