@@ -125,18 +125,52 @@ use thiserror::Error;
125125
126126static CUSTOM_TLDS : & [ & str ] = & [ "b32.i2p" ] ;
127127
128+ /// URL parsing errors that can occur during URL analysis.
129+ ///
130+ /// This enum represents all possible errors that can occur when parsing URLs
131+ /// using the faup-rs library. Each variant corresponds to a specific type
132+ /// of parsing failure, from invalid port numbers to malformed IP addresses.
128133#[ derive( Debug , Error ) ]
129134pub enum Error {
135+ /// Invalid port number encountered during URL parsing.
136+ ///
137+ /// This error occurs when a port number cannot be parsed as a valid u16 value.
138+ /// Port numbers must be between 0 and 65535.
130139 #[ error( "invalid port" ) ]
131140 InvalidPort ,
141+
142+ /// Invalid IPv4 address encountered during URL parsing.
143+ ///
144+ /// This error occurs when a string that should be an IPv4 address
145+ /// cannot be parsed according to IPv4 address standards.
132146 #[ error( "invalid ipv4 address" ) ]
133147 InvalidIPv4 ,
148+
149+ /// Invalid IPv6 address encountered during URL parsing.
150+ ///
151+ /// This error occurs when a string that should be an IPv6 address
152+ /// cannot be parsed according to IPv6 address standards.
134153 #[ error( "invalid ipv6 address" ) ]
135154 InvalidIPv6 ,
155+
156+ /// Invalid host encountered during URL parsing.
157+ ///
158+ /// This error occurs when a host string cannot be parsed as either
159+ /// a valid hostname or a valid IP address (IPv4 or IPv6).
136160 #[ error( "invalid host" ) ]
137161 InvalidHost ,
162+
163+ /// Generic error for other parsing issues.
164+ ///
165+ /// This error is used for various parsing problems that don't fit
166+ /// the more specific error categories.
138167 #[ error( "{0}" ) ]
139168 Other ( String ) ,
169+
170+ /// Parsing error from the underlying pest parser.
171+ ///
172+ /// This error occurs when the URL string doesn't conform to
173+ /// the expected grammar structure.
140174 #[ error( "parser error: {0}" ) ]
141175 Parse ( #[ from] Box < pest:: error:: Error < Rule > > ) ,
142176}
0 commit comments