-
Notifications
You must be signed in to change notification settings - Fork 4
/
result.h
27 lines (23 loc) · 900 Bytes
/
result.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#ifndef RESULT_H
#define RESULT_H
#include <stdbool.h>
typedef enum {
RESULT_SUCCESS, // Indicates successful operation
RESULT_FAIL_INIT, // Initialization failure
RESULT_FAIL_IO, // Input/output failure
RESULT_FAIL_NET, // Network related failure
RESULT_FAIL_ARG, // Invalid arguments provided
RESULT_FAIL_MEM, // Memory allocation failure
RESULT_FAIL_PERM, // Permissions or access failure
RESULT_FAIL_THREAD, // Thread related failure
RESULT_FAIL_UNKNOWN // Unknown or unspecified error
} Result_T;
#define CHECK_SUCCESS(X, MSG) \
do { \
Result_T r = X; \
if (r != RESULT_SUCCESS) { \
printf("%s [error: %i]\n", MSG, r); \
exit(1); \
} \
} while (false)
#endif // RESULT_H