LibGame v0.4.0
The LG Game Engine - Copyright (C) 2024-2026 ETMSoftware
Loading...
Searching...
No Matches
lg_error.c File Reference

Functions

int big_error (int big_error_code, const char *format,...)
 
void warning (int block, const char *format,...)
 
void lg_override_warning_timeout (int timeout)
 
void lg_reset_warning_timeout ()
 
long long lg_log_time ()
 
void lg_set_error_context (const char *file, unsigned int line, const char *func, const char *txt, int code)
 
int lg_get_error_context_code ()
 
const char * lg_get_full_error_context ()
 
void lg_clear_error_context ()
 
void lg_save_error_context (LG_ErrorContext *err_ctx)
 
void lg_restore_error_context (LG_ErrorContext *err_ctx)
 
int lg_push_error_context (LG_ErrorContext *err_ctx)
 
LG_ErrorContextlg_pop_error_context ()
 
void sig_handler (int sig_num, siginfo_t *sig_info, void *context)
 
void set_sig_handler ()
 
void lg_print_out_error_codes ()
 
void test_big_error (int test)
 

Variables

static LG_ErrorContext backup0
 
static LG_ErrorContextbackup = &backup0
 

Detailed Description

 === Errors handling ===

 TODO: complete the doc

Function Documentation

◆ big_error()

int big_error ( int  big_error_code,
const char *  format,
  ... 
)

This func's prototype is in libetm/error.h. This func is not defined in Libetm but in application and it handles CRITICAL ERRORS from both Libetm and application.

    NUA:

    "*** CRITICAL ERROR ***"
    if (big_error_code > LIBETM_LASTERRORCODE && big_error_code <= LG_LASTERRORCODE) {
            bla bla
    } else if (big_error_code >  LG_LASTERRORCODE) {
            bla bla
    }

◆ warning()

void warning ( int  block,
const char *  format,
  ... 
)

This func's prototype is in libetm/error.h. This func is not defined in Libetm but in application and it handles WARNINGS from both Libetm and application.

Will popup and wait for WARNING_TIMEOUT ms if no_block == TRUE, then close. Otherwise, will block until an appropriate keyboard/mouse action happens.

You can use BLOCK/NO_BLOCK helpers.

◆ lg_override_warning_timeout()

void lg_override_warning_timeout ( int  timeout)

Override warning timeout default value (= WARNING_TIMEOUT defined in lg_error.c)

Parameters
timeoutNew timeout in ms

◆ lg_reset_warning_timeout()

void lg_reset_warning_timeout ( )

Reset warning timeout to default value (= WARNING_TIMEOUT defined in lg_error.c)

◆ lg_log_time()

long long lg_log_time ( )

Log time for NOW - func name could be lg_now_time()

◆ lg_set_error_context()

void lg_set_error_context ( const char *  file,
unsigned int  line,
const char *  func,
const char *  txt,
int  code 
)

Set error context

Trying to find a way to trace back error origin

◆ lg_get_error_context_code()

int lg_get_error_context_code ( )

Get error context code

◆ lg_get_full_error_context()

const char * lg_get_full_error_context ( )

Get full error context code

◆ lg_clear_error_context()

void lg_clear_error_context ( )

Clear error context

◆ lg_save_error_context()

void lg_save_error_context ( LG_ErrorContext err_ctx)

Save error context

◆ lg_restore_error_context()

void lg_restore_error_context ( LG_ErrorContext err_ctx)

Restore error context

◆ lg_push_error_context()

int lg_push_error_context ( LG_ErrorContext err_ctx)

Push error context

◆ lg_pop_error_context()

LG_ErrorContext * lg_pop_error_context ( )

Pop error context

◆ sig_handler()

void sig_handler ( int  sig_num,
siginfo_t *  sig_info,
void *  context 
)

Set up the Unix signals handler

You must define app_sig_handler() somewhere in your app, so that you can get useful debugging info and exit properly

void app_sig_handler(int sig_num, const char *sig_txt)
{
INFO_ERR("%s received - will probably exit\n", sig_txt);
big_error(LG_SIG_START + sig_num, "%s received - this is a *bug*", sig_txt);
}
int big_error(int big_error_code, const char *format,...)
Definition lg_error.c:41

lg_error_code enum is defined in libgame.h

◆ set_sig_handler()

void set_sig_handler ( )

Handling a few UNIX signals

◆ lg_print_out_error_codes()

void lg_print_out_error_codes ( )

Print out error codes

◆ test_big_error()

void test_big_error ( int  test)

Testing big_error()