Xively Official / mbed-libxively-5d6fdd4

Dependents:   xively-jumpstart-demo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers xi_err.h Source File

xi_err.h

Go to the documentation of this file.
00001 // Copyright (c) 2003-2013, LogMeIn, Inc. All rights reserved.
00002 // This is part of Xively C library, it is under the BSD 3-Clause license.
00003 
00004 /**
00005  * \file    xi_err.h
00006  * \author  Olgierd Humenczuk
00007  * \brief   Error handling (POSIX-like)
00008  *
00009  *     * Every function should return a value
00010  *     * There are special values (usually `0` or `-1`) which indicate occurrence of an error
00011  *     * User can detect and lookup errors using declarations below
00012  */
00013 
00014 #ifndef __XI_ERR_H__
00015 #define __XI_ERR_H__
00016 
00017 #ifdef __cplusplus
00018 extern "C" {
00019 #endif
00020 
00021 typedef enum
00022 {
00023       XI_NO_ERR = 0
00024     , XI_OUT_OF_MEMORY
00025     , XI_HTTP_STATUS_PARSE_ERROR
00026     , XI_HTTP_HEADER_PARSE_ERROR
00027     , XI_HTTP_PARSE_ERROR
00028     , XI_HTTP_ENCODE_CREATE_DATASTREAM
00029     , XI_HTTP_ENCODE_UPDATE_DATASTREAM
00030     , XI_HTTP_ENCODE_GET_DATASTREAM
00031     , XI_HTTP_ENCODE_DELETE_DATASTREAM
00032     , XI_HTTP_ENCODE_DELETE_DATAPOINT
00033     , XI_HTTP_ENCODE_DELETE_RANGE_DATAPOINT
00034     , XI_HTTP_ENCODE_UPDATE_FEED
00035     , XI_HTTP_CONSTRUCT_REQUEST_BUFFER_OVERRUN
00036     , XI_HTTP_CONSTRUCT_CONTENT_BUFFER_OVERRUN
00037     , XI_CSV_ENCODE_DATAPOINT_BUFFER_OVERRUN
00038     , XI_CSV_ENCODE_DATASTREAM_BUFFER_OVERRUN
00039     , XI_CSV_DECODE_FEED_PARSER_ERROR
00040     , XI_CSV_DECODE_DATAPOINT_PARSER_ERROR
00041     , XI_CSV_TIME_CONVERTION_ERROR
00042     , XI_SOCKET_INITIALIZATION_ERROR
00043     , XI_SOCKET_GETHOSTBYNAME_ERROR
00044     , XI_SOCKET_CONNECTION_ERROR
00045     , XI_SOCKET_SHUTDOWN_ERROR
00046     , XI_SOCKET_WRITE_ERROR
00047     , XI_SOCKET_READ_ERROR
00048     , XI_SOCKET_CLOSE_ERROR
00049     , XI_DATAPOINT_VALUE_BUFFER_OVERFLOW
00050     , XI_ERR_COUNT
00051 } xi_err_t;
00052 
00053 #define XI_MAX_ERR_STRING 64
00054 
00055 /**
00056  * \brief   Error description lookup table
00057  */
00058 extern const char* xi_err_string[ XI_ERR_COUNT ];
00059 
00060 /**
00061  * \brief   Error getter for the user
00062  * \return  The `xi_err_t` structure which can be converted to a string using `xi_get_error_string()` method.
00063  *
00064  * \warning It resets the last error value, so it's always a good idea to make a copy of it!
00065  */
00066 extern xi_err_t xi_get_last_error( void );
00067 
00068 /**
00069  * \brief   Error setter for the library itself
00070  * \note    Current implementation used a global state variable (_errno_), which is not thread-safe.
00071  *          If thread-safety is required, than _errno_ should be made thread-local.
00072  */
00073 extern void xi_set_err( xi_err_t e );
00074 
00075 /**
00076  * \brief   Error description string getter for a given value of `xi_err_t`
00077  */
00078 extern const char* xi_get_error_string( xi_err_t e );
00079 
00080 #ifdef __cplusplus
00081 }
00082 #endif
00083 
00084 #endif // __XI_ERR_H__