libtcod
Loading...
Searching...
No Matches
error.h File Reference

Error handling module. More...

#include "config.h"
#include "version.h"

Go to the source code of this file.

Macros

#define TCOD_set_errorv(msg)
 Set an error with version, file, and line info added to the output.
#define TCOD_set_errorvf(fmt, ...)
 Format an error with version, file, and line info added to the output.

Typedefs

typedef enum TCOD_Error TCOD_Error
 An enum of libtcod error codes.

Enumerations

enum  TCOD_Error {
  TCOD_E_OK = 0 , TCOD_E_ERROR = -1 , TCOD_E_INVALID_ARGUMENT = -2 , TCOD_E_OUT_OF_MEMORY = -3 ,
  TCOD_E_REQUIRES_ATTENTION = -4 , TCOD_E_WARN = 1
}
 An enum of libtcod error codes. More...

Functions

const char * TCOD_get_error (void)
 Return the last error message.
TCOD_Error TCOD_set_error (const char *msg)
 Set an error message and return TCOD_E_ERROR.
TCOD_Error TCOD_set_errorf (const char *fmt,...)
 Set an error message and return TCOD_E_ERROR.
void TCOD_clear_error (void)
 Clear a current existing error message.

Detailed Description

Error handling module.

Macro Definition Documentation

◆ TCOD_set_errorv

#define TCOD_set_errorv ( msg)
Value:
TCOD_set_errorf("%s:%i\n%s", TCOD_STRVERSIONNAME " " __FILE__, __LINE__, (msg))
TCOD_Error TCOD_set_errorf(const char *fmt,...)
Set an error message and return TCOD_E_ERROR.
#define TCOD_STRVERSIONNAME
Definition version.h:81

Set an error with version, file, and line info added to the output.

Used internally.

◆ TCOD_set_errorvf

#define TCOD_set_errorvf ( fmt,
... )
Value:
TCOD_set_errorf("%s:%i\n" fmt, TCOD_STRVERSIONNAME " " __FILE__, __LINE__, __VA_ARGS__)

Format an error with version, file, and line info added to the output.

Used internally.

Typedef Documentation

◆ TCOD_Error

typedef enum TCOD_Error TCOD_Error

An enum of libtcod error codes.

On values other than TCOD_E_OK you can use TCOD_get_error() to learn more information.

embed:rst:leading-asterisk 
*  .. versionadded:: 1.16
*  

Enumeration Type Documentation

◆ TCOD_Error

enum TCOD_Error

An enum of libtcod error codes.

On values other than TCOD_E_OK you can use TCOD_get_error() to learn more information.

embed:rst:leading-asterisk 
*  .. versionadded:: 1.16
*  
Enumerator
TCOD_E_OK 

The function completed successfully without issues.

A function is successful when (err >= 0). Positive values may be used for warnings, or for other outputs.

TCOD_E_ERROR 

The error code for generic runtime errors.

The returned code my be changed in the future to something more specific. Use (err < 0) to check if the value is an error.

TCOD_E_INVALID_ARGUMENT 

The function failed because a given input argument was invalid.

TCOD_E_OUT_OF_MEMORY 

The function failed because it was unable to allocate enough memory.

TCOD_E_REQUIRES_ATTENTION 

This function needs additional attention, but is otherwise functioning correctly.

See its documentation.

embed:rst:leading-asterisk 
.. versionadded:: 1.16
TCOD_E_WARN 

The function completed, but a minor issue was detected.

Function Documentation

◆ TCOD_clear_error()

void TCOD_clear_error ( void )

Clear a current existing error message.

embed:rst:leading-asterisk 
*  .. versionadded:: 1.16
*  

◆ TCOD_get_error()

const char * TCOD_get_error ( void )

Return the last error message.

If there is no error then the string will have a length of zero.

embed:rst:leading-asterisk 
.. versionadded:: 1.12

◆ TCOD_set_error()

TCOD_Error TCOD_set_error ( const char * msg)

Set an error message and return TCOD_E_ERROR.

embed:rst:leading-asterisk 
.. versionadded:: 1.12

◆ TCOD_set_errorf()

TCOD_Error TCOD_set_errorf ( const char * fmt,
... )

Set an error message and return TCOD_E_ERROR.

embed:rst:leading-asterisk 
*  .. versionadded:: 1.16
*