diff --git a/.gitignore b/.gitignore index c6127b3..5e018db 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,8 @@ # Debug files *.dSYM/ +.idea/ +cmake-build-debug/ *.su *.idb *.pdb diff --git a/error.h b/error.h new file mode 100644 index 0000000..cf2ebe8 --- /dev/null +++ b/error.h @@ -0,0 +1,29 @@ +#ifndef ERROR_H +#define ERROR_H + +#include + +/** + * Error codes enum. + * SUCCESS = 0. + * ERROR < 0. + */ +typedef enum { + SRIX_SUCCESS, + NFC_ERROR = INT8_MIN, + SRIX_ERROR +} SrixErrorCode; + +/** + * Error structure that contains a description message. + */ +typedef struct SrixError { + SrixErrorCode errorType; + char const *message; +} SrixError; + +#define SRIX_NO_ERROR ((SrixError) {.errorType = SRIX_SUCCESS}) +#define SRIX_ERROR(type, errorMessage) ((SrixError) {.errorType = (type), .message = (errorMessage)}) +#define SRIX_IS_ERROR(isError) ((isError).errorType != SRIX_SUCCESS) + +#endif /* ERROR_H */ \ No newline at end of file