libclap 1.0.0
Command Line Argument Parser for C
Loading...
Searching...
No Matches
clap_error.h
Go to the documentation of this file.
1
6#ifndef CLAP_ERROR_H
7#define CLAP_ERROR_H
8
9#include <stdbool.h>
10#include <stdarg.h>
11#include <clap/clap_export.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17/* Error codes */
18#define CLAP_ERR_NONE 0
19#define CLAP_ERR_INVALID_ARGUMENT 1
20#define CLAP_ERR_MISSING_VALUE 2
21#define CLAP_ERR_TYPE_CONVERSION 3
22#define CLAP_ERR_INVALID_CHOICE 4
23#define CLAP_ERR_MUTUALLY_EXCLUSIVE 5
24#define CLAP_ERR_REQUIRED_MISSING 6
25#define CLAP_ERR_UNRECOGNIZED 7
26#define CLAP_ERR_TOO_MANY_ARGS 8
27#define CLAP_ERR_TOO_FEW_ARGS 9
28#define CLAP_ERR_MEMORY 10
29#define CLAP_ERR_SUBCOMMAND_FAILED 11
30#define CLAP_ERR_DEPENDENCY_VIOLATION 12
31#define CLAP_ERR_CUSTOM 100
32
36typedef struct clap_error_s {
37 int code;
38 char message[512];
39 const char *argument_name;
40 const char *invalid_value;
41 const char *subcommand_name;
43
51CLAP_EXPORT void clap_error_set(clap_error_t *error, int code, const char *format, ...);
52
59
66
67#ifdef __cplusplus
68}
69#endif
70
71#endif /* CLAP_ERROR_H */
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.
CLAP_EXPORT void clap_error_set(clap_error_t *error, int code, const char *format,...)
Set error code and printf-style message.
struct clap_error_s clap_error_t
Error information structure.
Symbol export/import macros for libclap.
#define CLAP_EXPORT
Definition clap_export.h:42
Error information structure.
Definition clap_error.h:36
int code
Definition clap_error.h:37
const char * invalid_value
Definition clap_error.h:40
char message[512]
Definition clap_error.h:38
const char * argument_name
Definition clap_error.h:39
const char * subcommand_name
Definition clap_error.h:41