@@ -31,7 +31,20 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
3131
3232 foreach ( var line in ipv4Lines )
3333 {
34- if ( ! IPAddress . TryParse ( line , out _ ) ) throw new Exception ( "Invalid IP Address in Cloudflare IPv4 Proxy list!" ) ;
34+ if ( ! IPAddress . TryParse ( line , out _ ) )
35+ {
36+ ctx . ReportDiagnostic ( Diagnostic . Create (
37+ new DiagnosticDescriptor (
38+ "CF001" ,
39+ "Invalid IP Address" ,
40+ $ "The entry '{ line } ' in { IpV4Name } is not a valid IP Address.",
41+ "CloudflareProxiesGenerator" ,
42+ DiagnosticSeverity . Error ,
43+ true ) ,
44+ Location . None ) ) ;
45+
46+ continue ; // Skip invalid entry
47+ }
3548
3649 sourceBuilder . Append ( " IPNetwork.Parse(\" " ) ;
3750 sourceBuilder . Append ( line ) ;
@@ -40,7 +53,20 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
4053 sourceBuilder . AppendLine ( "\n // IPv6" ) ;
4154 foreach ( var line in ipv6Lines )
4255 {
43- if ( ! IPAddress . TryParse ( line , out _ ) ) throw new Exception ( "Invalid IP Address in Cloudflare IPv6 Proxy list!" ) ;
56+ if ( ! IPAddress . TryParse ( line , out _ ) )
57+ {
58+ ctx . ReportDiagnostic ( Diagnostic . Create (
59+ new DiagnosticDescriptor (
60+ "CF001" ,
61+ "Invalid IP Address" ,
62+ $ "The entry '{ line } ' in { IpV6Name } is not a valid IP Address.",
63+ "CloudflareProxiesGenerator" ,
64+ DiagnosticSeverity . Error ,
65+ true ) ,
66+ Location . None ) ) ;
67+
68+ continue ; // Skip invalid entry
69+ }
4470
4571 sourceBuilder . Append ( " IPNetwork.Parse(\" " ) ;
4672 sourceBuilder . Append ( line ) ;
0 commit comments