diff options
| author | Laytan Laats <laytanlaats@hotmail.com> | 2025-04-05 15:53:11 +0200 |
|---|---|---|
| committer | Laytan Laats <laytanlaats@hotmail.com> | 2025-04-05 17:35:19 +0200 |
| commit | ff7d55a8e1ab8fd031378d9994f4aaf8394e7255 (patch) | |
| tree | 78e4dab5313eed54d40496f2aaa195972ff69347 /core/net/interface_windows.odin | |
| parent | f796b67a67bdd316ecf830b13cbd43fed7c0a64b (diff) | |
net: rework errors to be cross-platform
Diffstat (limited to 'core/net/interface_windows.odin')
| -rw-r--r-- | core/net/interface_windows.odin | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/core/net/interface_windows.odin b/core/net/interface_windows.odin index a6eb72846..571fb322f 100644 --- a/core/net/interface_windows.odin +++ b/core/net/interface_windows.odin @@ -23,7 +23,7 @@ package net import sys "core:sys/windows" import strings "core:strings" -_enumerate_interfaces :: proc(allocator := context.allocator) -> (interfaces: []Network_Interface, err: Network_Error) { +_enumerate_interfaces :: proc(allocator := context.allocator) -> (interfaces: []Network_Interface, err: Interfaces_Error) { context.allocator = allocator buf: []u8 @@ -52,7 +52,8 @@ _enumerate_interfaces :: proc(allocator := context.allocator) -> (interfaces: [] case 0: break gaa case: - return {}, Platform_Error(res) + set_last_platform_error(i32(res)) + return {}, .Unknown } } @@ -63,13 +64,13 @@ _enumerate_interfaces :: proc(allocator := context.allocator) -> (interfaces: [] _interfaces := make([dynamic]Network_Interface, 0, allocator) for adapter := (^sys.IP_Adapter_Addresses)(raw_data(buf)); adapter != nil; adapter = adapter.Next { friendly_name, err1 := sys.wstring_to_utf8(sys.wstring(adapter.FriendlyName), 256, allocator) - if err1 != nil { return {}, Platform_Error(err1) } + if err1 != nil { return {}, .Allocation_Failure } description, err2 := sys.wstring_to_utf8(sys.wstring(adapter.Description), 256, allocator) - if err2 != nil { return {}, Platform_Error(err2) } + if err2 != nil { return {}, .Allocation_Failure } dns_suffix, err3 := sys.wstring_to_utf8(sys.wstring(adapter.DnsSuffix), 256, allocator) - if err3 != nil { return {}, Platform_Error(err3) } + if err3 != nil { return {}, .Allocation_Failure } interface := Network_Interface{ adapter_name = strings.clone(string(adapter.AdapterName)), @@ -176,4 +177,4 @@ parse_socket_address :: proc(addr_in: sys.SOCKET_ADDRESS) -> (addr: Endpoint) { case: return // Empty or invalid address type } unreachable() -}
\ No newline at end of file +} |