os2: make platform error more ergonomic by making it an alias

This commit is contained in:
Laytan Laats
2024-08-22 22:59:13 +02:00
parent 142bda2804
commit b9043db434
4 changed files with 8 additions and 2 deletions
+1 -1
View File
@@ -30,7 +30,7 @@ General_Error :: enum u32 {
Unsupported, Unsupported,
} }
Platform_Error :: enum i32 {None=0} Platform_Error :: _Platform_Error
Error :: union #shared_nil { Error :: union #shared_nil {
General_Error, General_Error,
+2
View File
@@ -3,6 +3,8 @@ package os2
import "core:sys/linux" import "core:sys/linux"
_Platform_Error :: linux.Errno
@(rodata) @(rodata)
_errno_strings := [linux.Errno]string{ _errno_strings := [linux.Errno]string{
.NONE = "", .NONE = "",
+2
View File
@@ -4,6 +4,8 @@ package os2
import "core:sys/posix" import "core:sys/posix"
_Platform_Error :: posix.Errno
_error_string :: proc(errno: i32) -> string { _error_string :: proc(errno: i32) -> string {
return string(posix.strerror(posix.Errno(errno))) return string(posix.strerror(posix.Errno(errno)))
} }
+2
View File
@@ -5,6 +5,8 @@ import "base:runtime"
import "core:slice" import "core:slice"
import win32 "core:sys/windows" import win32 "core:sys/windows"
_Platform_Error :: win32.System_Error
_error_string :: proc(errno: i32) -> string { _error_string :: proc(errno: i32) -> string {
e := win32.DWORD(errno) e := win32.DWORD(errno)
if e == 0 { if e == 0 {