src/lib/errors.h
author Tero Marttila <terom@fixme.fi>
Thu, 28 May 2009 01:17:36 +0300
branchnew-lib-errors
changeset 219 cefec18b8268
parent 218 5229a5d098b2
permissions -rw-r--r--
some of the lib/transport stuff compiles
#ifndef LIBQMSK_ERRORS_H
#define LIBQMSK_ERRORS_H

/**
 * @file
 *
 * Defines some errors codes for general-purpose use, or for common libraries.
 */
#include "error.h"

/**
 * General-purpose errors that may be useful and don't belong in any more specific namespace.
 */
enum general_error_code {
    ERR_GENERAL_NONE,
    ERR_MEM,                ///< memory allocation error
    ERR_NOT_IMPLEMENTED,    ///< function not implmented: <func>
    ERR_MISC,               ///< miscellaneous error: <error>
    ERR_CMD_OPT,            ///< invalid command line option: <error> - XXX: replace with something getopt
    ERR_UNKNOWN,            ///< unknown error
};

const struct error_list general_errors;

/**
 * Convenience macros
 */
#define SET_ERROR_MEM(err_state) \
    SET_ERROR(err_state, &general_errors, ERR_MEM)

/**
 * Errors for POSIX libc functions
 */
enum libc_error_code {
    ERR_LIBC_NONE,
    ERR_SIGACTION,          ///< sigaction: <perror>
    ERR_READ,               ///< read: <perror>
    ERR_WRITE,              ///< write: <perror>
    ERR_WRITE_EOF,          ///< write: EOF
    ERR_FCNTL,              ///< fcntl: <perror>
    ERR_CLOSE,              ///< close: <perror>
};

const struct error_list libc_errors;

/**
 * Errors for libevent
 */
enum libevent_error_code {
    ERR_EVENT_NONE,
    ERR_EVENT_NEW,          ///< event_new
    ERR_EVENT_ADD,          ///< event_add
    ERR_EVENT_DEL,          ///< event_del
};

const struct error_list libevent_errors;

/**
 * Errors for lua
 */
enum lua_error_code {
    ERR_LUA_NONE,
    ERR_LUA_MEM,            ///< memory error
    ERR_LUA_SYNTAX,         ///< syntax error
    ERR_LUA_RUN,            ///< runtime erorr
    ERR_LUA_ERR,            ///< error-handling error
    ERR_LUA_FILE,           ///< filesystem error
};

const struct error_list lua_errors;

#endif /* LIBQMSK_ERRORS_H */