Result status codes#
This project adopts widely used convention of returning integer encoded status codes as function results.
Each function, that needs to notify it’s execution status (success or error),
returns lsp_status_t
(alias for lsp_int8_t
).
Available status codes are:
LSP_SUCCESS
Execution successful.
LSP_EOF
End of file encountered during reading/writing.
LSP_ERR
Generic error (unknown error).
LSP_ERR_MEM
Memory error (usually out of memory).
LSP_ERR_CTX
Context error (usually symbol resolution error).
LSP_ERR_READ
Reader error.
LSP_ERR_WRITE
Writer error.
LSP_ERR_EVAL
Evaluation error.
LSP_ERR_APPLY
Application error.
LSP_ERR_ARG_COUNT
Invalid argument count.
LSP_ERR_ARG_TYPE
Invalid argument type.
LSP_ERR_ARG_VALUE
Invalid argument value.
LSP_ERR_USER
Special status value representing beginning of user status codes.
User has ability to raise user error with error
builtin function. This
error is additionally described with integer value in range [0, 126] and
encoded as status code.
Source code#
status.h#
#ifndef LSP_STATUS_H
#define LSP_STATUS_H
#include "arch.h"
#define LSP_STATUS(x) ((lsp_status_t)x)
#define LSP_SUCCESS LSP_STATUS(0)
#define LSP_EOF LSP_STATUS(-1)
#define LSP_ERR LSP_STATUS(1)
#define LSP_ERR_MEM LSP_STATUS(2)
#define LSP_ERR_CTX LSP_STATUS(3)
#define LSP_ERR_READ LSP_STATUS(4)
#define LSP_ERR_WRITE LSP_STATUS(5)
#define LSP_ERR_EVAL LSP_STATUS(6)
#define LSP_ERR_APPLY LSP_STATUS(7)
#define LSP_ERR_ARG_COUNT LSP_STATUS(8)
#define LSP_ERR_ARG_TYPE LSP_STATUS(9)
#define LSP_ERR_ARG_VALUE LSP_STATUS(10)
#define LSP_ERR_USER LSP_STATUS(0x80)
typedef lsp_int8_t lsp_status_t;
#endif