Skip to content

Commit

Permalink
error handle
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikPelli committed May 25, 2021
1 parent 9c729ef commit caf31c8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

# Debug files
*.dSYM/
.idea/
cmake-build-debug/
*.su
*.idb
*.pdb
Expand Down
29 changes: 29 additions & 0 deletions error.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef ERROR_H
#define ERROR_H

#include <stdint.h>

/**
* 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 */

0 comments on commit caf31c8

Please sign in to comment.