libclap 1.0.0
Command Line Argument Parser for C
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions
clap_error.h File Reference

Error handling for libclap. More...

#include <stdbool.h>
#include <stdarg.h>
#include <clap/clap_export.h>
Include dependency graph for clap_error.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  clap_error_s
 Error information structure. More...
 

Macros

#define CLAP_ERR_NONE   0
 
#define CLAP_ERR_INVALID_ARGUMENT   1
 
#define CLAP_ERR_MISSING_VALUE   2
 
#define CLAP_ERR_TYPE_CONVERSION   3
 
#define CLAP_ERR_INVALID_CHOICE   4
 
#define CLAP_ERR_MUTUALLY_EXCLUSIVE   5
 
#define CLAP_ERR_REQUIRED_MISSING   6
 
#define CLAP_ERR_UNRECOGNIZED   7
 
#define CLAP_ERR_TOO_MANY_ARGS   8
 
#define CLAP_ERR_TOO_FEW_ARGS   9
 
#define CLAP_ERR_MEMORY   10
 
#define CLAP_ERR_SUBCOMMAND_FAILED   11
 
#define CLAP_ERR_DEPENDENCY_VIOLATION   12
 
#define CLAP_ERR_CUSTOM   100
 

Typedefs

typedef struct clap_error_s clap_error_t
 Error information structure.
 

Functions

CLAP_EXPORT void clap_error_set (clap_error_t *error, int code, const char *format,...)
 Set error code and printf-style message.
 
CLAP_EXPORT int clap_error_code (const clap_error_t *error)
 Get the error code from an error structure.
 
CLAP_EXPORT const char * clap_error_message (const clap_error_t *error)
 Get the human-readable message from an error structure.
 

Detailed Description

Error handling for libclap.

Macro Definition Documentation

◆ CLAP_ERR_CUSTOM

#define CLAP_ERR_CUSTOM   100

◆ CLAP_ERR_DEPENDENCY_VIOLATION

#define CLAP_ERR_DEPENDENCY_VIOLATION   12

◆ CLAP_ERR_INVALID_ARGUMENT

#define CLAP_ERR_INVALID_ARGUMENT   1

◆ CLAP_ERR_INVALID_CHOICE

#define CLAP_ERR_INVALID_CHOICE   4

◆ CLAP_ERR_MEMORY

#define CLAP_ERR_MEMORY   10

◆ CLAP_ERR_MISSING_VALUE

#define CLAP_ERR_MISSING_VALUE   2

◆ CLAP_ERR_MUTUALLY_EXCLUSIVE

#define CLAP_ERR_MUTUALLY_EXCLUSIVE   5

◆ CLAP_ERR_NONE

#define CLAP_ERR_NONE   0

◆ CLAP_ERR_REQUIRED_MISSING

#define CLAP_ERR_REQUIRED_MISSING   6

◆ CLAP_ERR_SUBCOMMAND_FAILED

#define CLAP_ERR_SUBCOMMAND_FAILED   11

◆ CLAP_ERR_TOO_FEW_ARGS

#define CLAP_ERR_TOO_FEW_ARGS   9

◆ CLAP_ERR_TOO_MANY_ARGS

#define CLAP_ERR_TOO_MANY_ARGS   8

◆ CLAP_ERR_TYPE_CONVERSION

#define CLAP_ERR_TYPE_CONVERSION   3

◆ CLAP_ERR_UNRECOGNIZED

#define CLAP_ERR_UNRECOGNIZED   7

Typedef Documentation

◆ clap_error_t

typedef struct clap_error_s clap_error_t

Error information structure.

Function Documentation

◆ clap_error_code()

CLAP_EXPORT int clap_error_code ( const clap_error_t error)

Get the error code from an error structure.

Parameters
errorError struct (must not be NULL).
Returns
The CLAP_ERR_* code.

◆ clap_error_message()

CLAP_EXPORT const char * clap_error_message ( const clap_error_t error)

Get the human-readable message from an error structure.

Parameters
errorError struct (must not be NULL).
Returns
Pointer to the internal message buffer. Never returns NULL.

◆ clap_error_set()

CLAP_EXPORT void clap_error_set ( clap_error_t error,
int  code,
const char *  format,
  ... 
)

Set error code and printf-style message.

Parameters
errorError struct to fill.
codeError code (CLAP_ERR_* constant).
formatprintf-style format string.
...printf arguments.