EtcPal  0.4.1
ETC Platform Abstraction Layer (EtcPal)
View other versions:
error (Error Handling)

Overview

Platform-neutral error codes.

include "etcpal/error.h"

Provides a set of error codes that can be returned by library functions. For platform abstraction modules, error codes are translated from their platform-specific counterparts. Use etcpal_strerror() to get a string representation of any error code.

Macros

#define ETCPAL_NUM_ERROR_CODES   31
 The total number of error codes currently defined.
 

Enumerations

enum  etcpal_error_t {
  kEtcPalErrOk = 0 , kEtcPalErrNotFound = -1 , kEtcPalErrNoMem = -2 , kEtcPalErrBusy = -3 ,
  kEtcPalErrExists = -4 , kEtcPalErrInvalid = -5 , kEtcPalErrWouldBlock = -6 , kEtcPalErrNoData = -7 ,
  kEtcPalErrProtocol = -8 , kEtcPalErrMsgSize = -9 , kEtcPalErrAddrInUse = -10 , kEtcPalErrAddrNotAvail = -11 ,
  kEtcPalErrNetwork = -12 , kEtcPalErrConnReset = -13 , kEtcPalErrConnClosed = -14 , kEtcPalErrIsConn = -15 ,
  kEtcPalErrNotConn = -16 , kEtcPalErrShutdown = -17 , kEtcPalErrTimedOut = -18 , kEtcPalErrHostUnreach = -19 ,
  kEtcPalErrConnAborted = -20 , kEtcPalErrConnRefused = -21 , kEtcPalErrAlready = -22 , kEtcPalErrInProgress = -23 ,
  kEtcPalErrBufSize = -24 , kEtcPalErrNotInit = -25 , kEtcPalErrNoNetints = -26 , kEtcPalErrNoSockets = -27 ,
  kEtcPalErrNotImpl = -28 , kEtcPalErrPerm = -29 , kEtcPalErrSys = -30
}
 A set of error codes that can be returned by library functions. More...
 

Functions

const char * etcpal_strerror (etcpal_error_t code)
 Get a string representation of an error code. More...
 

Enumeration Type Documentation

◆ etcpal_error_t

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

Enumerator
kEtcPalErrOk 

The call was successful, no error occurred.

kEtcPalErrNotFound 

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

kEtcPalErrNoMem 

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

kEtcPalErrBusy 

The resource being requested is temporarily unavailable.

kEtcPalErrExists 

The item being created already exists.

kEtcPalErrInvalid 

An invalid argument was provided to an API function.

kEtcPalErrWouldBlock 

The requested operation would block.

kEtcPalErrNoData 

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

kEtcPalErrProtocol 

A protocol parsing function encountered a malformed packet.

kEtcPalErrMsgSize 

Message too long.

kEtcPalErrAddrInUse 

The requested address is already in use.

kEtcPalErrAddrNotAvail 

Cannot assign the requested address.

kEtcPalErrNetwork 

The operation failed because a network was down or unreachable.

kEtcPalErrConnReset 

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

kEtcPalErrConnClosed 

A connection was gracefully closed by the remote peer.

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

kEtcPalErrIsConn 

Transport endpoint is already connected.

kEtcPalErrNotConn 

Transport endpoint is not connected.

kEtcPalErrShutdown 

Transport endpoint is shut down.

kEtcPalErrTimedOut 

A connection timed out.

kEtcPalErrHostUnreach 

Host is unreachable.

kEtcPalErrConnAborted 

A connection has been aborted.

kEtcPalErrConnRefused 

A connection was refused.

kEtcPalErrAlready 

The operation requested is already in progress.

kEtcPalErrInProgress 

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

kEtcPalErrBufSize 

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

kEtcPalErrNotInit 

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

kEtcPalErrNoNetints 

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

kEtcPalErrNoSockets 

No sockets have been added to the context.

kEtcPalErrNotImpl 

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

kEtcPalErrPerm 

The operation is not permitted.

kEtcPalErrSys 

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

Function Documentation

◆ etcpal_strerror()

const char* etcpal_strerror ( etcpal_error_t  code)

Get a string representation of an error code.

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