-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.h
34 lines (28 loc) · 863 Bytes
/
error.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
28
29
30
31
32
33
34
#ifndef __ERROR__
#define __ERROR__
#include <string.h>
//*****************************************************************************************
// ERROR STRUCTURE
/*
Structure used to handle errors. The member 'code' will be '1' when there is
no error, and '-1' when there was an error. The message of the error should
be in the 'msg' member.
*/
typedef struct
{
// The code: 1 for no error, and -1 for error.
int code;
// The massage asociated to the error.
char msg[200];
} Error;
//***********************************
// ERROR METHODS
// Function for easy code and message setting.
// Put the 'code' and 'msg' in the 'error' instance.
void Error_Set(Error *error, int code, const char *msg)
{
error->code = code;
strcpy(error->msg, msg);
}
//*****************************************************************************************
#endif