src/lib/errors.h
branchnew-lib-errors
changeset 218 5229a5d098b2
child 219 cefec18b8268
equal deleted inserted replaced
217:7728d6ec3abf 218:5229a5d098b2
       
     1 #ifndef LIBQMSK_ERRORS_H
       
     2 #define LIBQMSK_ERRORS_H
       
     3 
       
     4 /**
       
     5  * @file
       
     6  *
       
     7  * Defines some errors codes for general-purpose use, or for common libraries.
       
     8  */
       
     9 #include "error.h"
       
    10 
       
    11 /**
       
    12  * General-purpose errors that may be useful and don't belong in any more specific namespace.
       
    13  */
       
    14 enum general_error_code {
       
    15     ERR_GENERAL_NONE,
       
    16     ERR_MEM,                ///< memory allocation error
       
    17     ERR_NOT_IMPLEMENTED,    ///< function not implmented: <func>
       
    18     ERR_MISC,               ///< miscellaneous error: <error>
       
    19     ERR_CMD_OPT,            ///< invalid command line option: <error> - XXX: replace with something getopt
       
    20     ERR_UNKNOWN,            ///< unknown error
       
    21 };
       
    22 
       
    23 const struct error_list general_errors;
       
    24 
       
    25 /**
       
    26  * Convenience macros
       
    27  */
       
    28 #define SET_ERROR_MEM(err_state) \
       
    29     SET_ERROR(err_state, &general_errors, ERR_MEM)
       
    30 
       
    31 /**
       
    32  * Errors for POSIX libc functions
       
    33  */
       
    34 enum libc_error_code {
       
    35     ERR_LIBC_NONE,
       
    36     ERR_SIGACTION,          ///< sigaction: <perror>
       
    37 };
       
    38 
       
    39 const struct error_list libc_errors;
       
    40 
       
    41 /**
       
    42  * Errors for libevent
       
    43  */
       
    44 enum libevent_error_code {
       
    45     ERR_EVENT_NEW,          ///< event_new
       
    46     ERR_EVENT_ADD,          ///< event_add
       
    47     ERR_EVENT_DEL,          ///< event_del
       
    48 };
       
    49 
       
    50 const struct error_list libevent_errors;
       
    51 
       
    52 #endif /* LIBQMSK_ERRORS_H */