Kore 3
Loading...
Searching...
No Matches
error.h File Reference

Contains functionality to stop the program in case of an error and create a user-visible error message. More...

#include <kore3/global.h>
#include <stdarg.h>

Go to the source code of this file.

Functions

KORE_FUNC void kore_affirm (bool condition)
 Exits the program when a condition is untrue and shows a generic error message.
KORE_FUNC void kore_affirm_message (bool condition, const char *format,...)
 Exits the program when a condition is untrue and shows a provided error message.
KORE_FUNC void kore_affirm_args (bool condition, const char *format, va_list args)
 Equivalent to kore_affirm_message but uses a va_list parameter.
KORE_FUNC void kore_error (void)
 Exits the program and shows a generic error message.
KORE_FUNC void kore_error_message (const char *format,...)
 Exits the program and shows a provided error message.
KORE_FUNC void kore_error_args (const char *format, va_list args)
 Equivalent to kore_error_message but uses a va_list parameter.

Detailed Description

Contains functionality to stop the program in case of an error and create a user-visible error message.

The affirm and error functions print an error message and then exit the program. Error messages can be made visible to the user (unless a console window is active this is only implemented for Windows).

Function Documentation

◆ kore_affirm()

KORE_FUNC void kore_affirm ( bool condition)

Exits the program when a condition is untrue and shows a generic error message.

This is an alternative to assert which also persists in release builds. Use this instead of assert in situations where you want your users to see what's going wrong. This uses Kore's log and error functionality to make errors visible.

Parameters
conditionExits the program if condition is false, otherwise does nothing.

◆ kore_affirm_args()

KORE_FUNC void kore_affirm_args ( bool condition,
const char * format,
va_list args )

Equivalent to kore_affirm_message but uses a va_list parameter.

You will need this if you want to provide the parameters using va_start/va_end.

Parameters
conditionExits the program if condition is false, otherwise does nothing.
formatThe parameter is equivalent to the first vprintf parameter.
...The parameter is equivalent to the second vprintf parameter.

◆ kore_affirm_message()

KORE_FUNC void kore_affirm_message ( bool condition,
const char * format,
... )

Exits the program when a condition is untrue and shows a provided error message.

This is equivalent to kore_affirm() but uses the provided message instead of a generic one.

Parameters
conditionExits the program if condition is false, otherwise does nothing.
formatThe parameter is equivalent to the first printf parameter.
...The parameter is equivalent to the second printf parameter.

◆ kore_error()

KORE_FUNC void kore_error ( void )

Exits the program and shows a generic error message.

Mainly this just calls exit(EXIT_FAILURE) but will also use Kore's log function and on Windows show an error message box.

◆ kore_error_args()

KORE_FUNC void kore_error_args ( const char * format,
va_list args )

Equivalent to kore_error_message but uses a va_list parameter.

You will need this if you want to provide the parameters using va_start/va_end.

Parameters
formatThe parameter is equivalent to the first vprintf parameter.
...The parameter is equivalent to the second vprintf parameter.

◆ kore_error_message()

KORE_FUNC void kore_error_message ( const char * format,
... )

Exits the program and shows a provided error message.

This is equivalent to kore_error() but uses the provided message instead of a generic one.

Parameters
formatThe parameter is equivalent to the first printf parameter.
...The parameter is equivalent to the second printf parameter.