2024-02-08 19:33:53 -08:00
|
|
|
package sectr
|
|
|
|
|
|
|
|
import "base:runtime"
|
|
|
|
import "core:os"
|
|
|
|
|
|
|
|
ensure :: proc( condition : b32, msg : string, location := #caller_location )
|
|
|
|
{
|
2024-02-23 06:36:23 -08:00
|
|
|
if condition {
|
2024-02-08 19:33:53 -08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
log( msg, LogLevel.Warning, location )
|
|
|
|
runtime.debug_trap()
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO(Ed) : Setup exit codes!
|
2024-02-23 06:36:23 -08:00
|
|
|
fatal :: proc( msg : string, exit_code : int = -1, location := #caller_location )
|
2024-02-08 19:33:53 -08:00
|
|
|
{
|
|
|
|
log( msg, LogLevel.Fatal, location )
|
|
|
|
runtime.debug_trap()
|
|
|
|
os.exit( exit_code )
|
|
|
|
}
|
|
|
|
|
2024-02-23 06:36:23 -08:00
|
|
|
verify :: proc( condition : b32, msg : string, exit_code : int = -1, location := #caller_location )
|
2024-02-08 19:33:53 -08:00
|
|
|
{
|
2024-02-23 06:36:23 -08:00
|
|
|
if condition {
|
2024-02-08 19:33:53 -08:00
|
|
|
return
|
|
|
|
}
|
|
|
|
log( msg, LogLevel.Fatal, location )
|
|
|
|
runtime.debug_trap()
|
|
|
|
os.exit( exit_code )
|
|
|
|
}
|