lwpa  0.1.0
LightWeight Platform Abstraction (lwpa)
View other versions:
lwpa_error

Overview

Platform-neutral error codes.

#include "lwpa_error.h"

Macros

#define LWPA_NUM_ERROR_CODES   27
 
#define lwpa_strerror(errcode)    (((int)errcode <= 0 && (int)errcode > -LWPA_NUM_ERROR_CODES) ? lwpa_error_strings[-((int)errcode)] : NULL)
 Get a string representation of an error code. More...
 

Enumerations

enum  lwpa_error_t {
  LWPA_OK = 0 , LWPA_NOTFOUND = -1 , LWPA_NOMEM = -2 , LWPA_BUSY = -3 ,
  LWPA_EXIST = -4 , LWPA_INVALID = -5 , LWPA_WOULDBLOCK = -6 , LWPA_NODATA = -7 ,
  LWPA_PROTERR = -8 , LWPA_MSGSIZE = -9 , LWPA_ADDRINUSE = -10 , LWPA_ADDRNOTAVAIL = -11 ,
  LWPA_NETERR = -12 , LWPA_CONNRESET = -13 , LWPA_CONNCLOSED = -14 , LWPA_ISCONN = -15 ,
  LWPA_NOTCONN = -16 , LWPA_SHUTDOWN = -17 , LWPA_TIMEDOUT = -18 , LWPA_CONNREFUSED = -19 ,
  LWPA_ALREADY = -20 , LWPA_INPROGRESS = -21 , LWPA_BUFSIZE = -22 , LWPA_NOTINIT = -23 ,
  LWPA_NOIFACES = -24 , LWPA_NOTIMPL = -25 , LWPA_SYSERR = -26
}
 A set of error codes that can be returned by library functions. More...
 

Variables

const char * lwpa_error_strings [LWPA_NUM_ERROR_CODES]
 

Macro Definition Documentation

◆ lwpa_strerror

#define lwpa_strerror (   errcode)     (((int)errcode <= 0 && (int)errcode > -LWPA_NUM_ERROR_CODES) ? lwpa_error_strings[-((int)errcode)] : NULL)

Get a string representation of an error code.

Parameters
errcodelwpa error code.
Returns
Error string (char *) (valid error code) or NULL (invalid error code).

Enumeration Type Documentation

◆ lwpa_error_t

A set of error codes that can be returned by library functions.

Enumerator
LWPA_OK 

The call was successful, no error occurred.

LWPA_NOTFOUND 

An identifier or handle passed to a function was not valid or not previously initialized.

LWPA_NOMEM 

A dynamic memory allocation failed, or there is no space left in a statically allocated array.

LWPA_BUSY 

The resource being requested is temporarily unavailable.

LWPA_EXIST 

The item being created already exists.

LWPA_INVALID 

An invalid argument was provided to an API function.

LWPA_WOULDBLOCK 

The requested operation would block.

LWPA_NODATA 

Returned from a function that is meant to be called repeatedly to indicate that there is no more data available.

LWPA_PROTERR 

A protocol parsing function encountered a malformed packet.

LWPA_MSGSIZE 

Message too long.

LWPA_ADDRINUSE 

The requested address is already in use.

LWPA_ADDRNOTAVAIL 

Cannot assign the requested address.

LWPA_NETERR 

The operation failed because a network was down or unreachable.

LWPA_CONNRESET 

A connection was reset (hard/abortive close) by the remote peer.

LWPA_CONNCLOSED 

A connection was gracefully closed by the remote peer.

This code is only used for protocols above the transport layer.

LWPA_ISCONN 

Transport endpoint is already connected.

LWPA_NOTCONN 

Transport endpoint is not connected.

LWPA_SHUTDOWN 

Transport endpoint is shut down.

LWPA_TIMEDOUT 

A connection timed out.

LWPA_CONNREFUSED 

A connection was refused.

LWPA_ALREADY 

The operation requested is already in progress.

LWPA_INPROGRESS 

The operation requested is now in progress and will complete later.

LWPA_BUFSIZE 

A buffer provided to a function was not big enough to hold the data that needed to be packed into it.

LWPA_NOTINIT 

An API function was called from a module that was not previously initialized.

LWPA_NOIFACES 

No network interfaces were found on the system, or there are no network interfaces of a type that can satisfy the call being made.

LWPA_NOTIMPL 

A function or specific use of a function is not implemented yet.

LWPA_SYSERR 

A system call or C library call failed in a way not covered by other errors.