aboutsummaryrefslogtreecommitdiff
path: root/include/libtio/error.h
blob: f2a7b9e9f3a38aae4c538e755a227035ecfb06b8 (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef  LIBTIO_ERROR_H
# define LIBTIO_ERROR_H 20180710
# include "cdefs.h"

TIO_BEGIN_NAMESPACE

/* ---
 * Error codes.
 * --- */

typedef int tio_error_t;

# define tio_ok             0x00
# define tio_error_none     0x00
# define tio_error_success  0x00
# define tio_error_ok       0x00

/* General errors.
 * `unknown`: an unknown error has occurred.
 * `alloc`: a memory allocation has failed.
 * `op`: unsupported operation.
 * `arg`: an argument was invalid.
 * `iter`: no more elements in the iterator.
 * `notfound`: error not found.
 * `access`: access denied. */

# define tio_error_unknown  0x01
# define tio_error_alloc    0x02
# define tio_error_op       0x03
# define tio_error_arg      0x04
# define tio_error_iter     0x05
# define tio_error_notfound 0x06
# define tio_error_access   0x07

/* Stream errors.
 * `stream`: invalid stream or stream in erroneous state (parent, …).
 * `read`: a read operation has failed.
 * `write`: a write operation has failed.
 * `seek`: a seek operation has failed.
 * `end`: an end of stream event has occured.
 * `timeout`: a timeout operation has failed.
 * `scsi`: an SCSI operation has failed.
 * `usb`: a USB operation has failed. */

# define tio_error_stream   0x10
# define tio_error_read     0x11
# define tio_error_write    0x12
# define tio_error_seek     0x13
# define tio_error_end      0x14
# define tio_error_timeout  0x15
# define tio_error_scsi     0x16
# define tio_error_usb      0x17

/* ---
 * Utilities.
 * --- */

/* Get the error name or description. */

TIO_EXTERN(char const *) tio_error_name
	OF((int tio__code));
TIO_EXTERN(char const *) tio_error_desc
	OF((int tio__code));

TIO_END_NAMESPACE

#endif /* LIBTIO_ERROR_H */