Skip to content

Commit

Permalink
Handle all errors on std.net.Ipv4address.resolveIP
Browse files Browse the repository at this point in the history
The following test fails since NonCanonical is not handled

test "foo" {
    std.net.Ip4Address.resolveIp("1.1.1.1", 0) catch unreachable;
}

/usr/lib/zig/std/net.zig:240:60: error: switch must handle all possibilities
        if (parse(name, port)) |ip4| return ip4 else |err| switch (err) {
                                                           ^~~~~~
/usr/lib/zig/std/net.zig:240:60: note: unhandled error value: 'error.NonCanonical'
referenced by:
    test.foo: src/dhcp.zig:383:23
  • Loading branch information
haesbaert authored and Vexu committed Jan 21, 2024
1 parent 2e7d28d commit bf7ebfa
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions lib/std/net.zig
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ pub const Ip4Address = extern struct {
error.InvalidEnd,
error.InvalidCharacter,
error.Incomplete,
error.NonCanonical,
=> {},
}
return error.InvalidIPAddressFormat;
Expand Down

0 comments on commit bf7ebfa

Please sign in to comment.