-
Notifications
You must be signed in to change notification settings - Fork 1
/
error.c
46 lines (41 loc) · 855 Bytes
/
error.c
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
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include "error.h"
#include "debug.h"
//----------------------------------------------------------------------------
error_t error (error_t err)
{
int disp = 1;
INFOF("! ");
switch (err) {
case ERR_OK:
INFOF("No error\n");
disp = 0;
break;
case ERR_NULL:
INFOF("NULL pointer\n");
disp = 0;
break;
case ERR_NOTTY:
INFOF("Unable to open device. Ensure it is not in use by another application\n");
break;
case ERR_RDATTR:
INFOF("\n");
break;
case ERR_TXFAIL:
INFOF("Write Fail");
break;
case ERR_RXFAIL:
INFOF("Read Fail");
break;
case ERR_INITFAIL:
INFOF("Failed to initialise the chatpadB");
break;
default:
INFOF("Error #%d", err);
break;
}
if (disp) INFOF(" (%d - %s)\n", errno, strerror(errno)) ;
return err;
}