squareball/sb-error.h File Reference

Error reporting infrastructure. More...

#include <stdarg.h>

Go to the source code of this file.

Data Structures

struct  sb_error_t



enum  { SB_ERROR_FILE_OPEN = -1, SB_ERROR_FILE_READ = -2, SB_ERROR_FILE_WRITE = -3, SB_ERROR_DIR_CREATE = -4 }
sb_error_tsb_error_new (int code, const char *msg)
sb_error_tsb_error_new_printf (int code, const char *format,...)
void sb_error_free (sb_error_t *err)

Detailed Description

Error reporting infrastructure.

This implementation is meant to be simple and easy to use, without global variables, etc. If user needs something more advanced, like support to repeated error codes, splitted error types for each type of error, etc., such solution should be implemented in the application itself.


Enumeration Type Documentation

anonymous enum

Internal error codes.

This is an enum with all error codes used by squareball library itself. They start from 262144 (0x1000000) to avoid conflicts with application error codes.


Function Documentation

void sb_error_free ( sb_error_t err  ) 

Function that frees memory allocated for an error object.

Parameters:
err An error object.
Examples:
hello_dir_create.c, hello_file_read.c, and hello_file_write.c.
sb_error_t* sb_error_new ( int  code,
const char *  msg 
)

Function that creates a new error object.

Parameters:
code Error code.
msg Human-readable error message.
Returns:
An error object.
sb_error_t* sb_error_new_printf ( int  code,
const char *  format,
  ... 
)

Function that creates a new error object, with printf(3)-like message formatting.

Parameters:
code Error code.
format Format for human-readable error message.
... One or more printf(3)-like parameters.
Returns:
An error object.

Generated on 5 Apr 2016 for squareball by  doxygen 1.6.1