src
lib
detail
error_handler.cpp
Go to the documentation of this file.
1
9
/*****************************************************************************
10
** Cross platform
11
*****************************************************************************/
12
13
#include <ecl/config/ecl.hpp>
14
15
/*****************************************************************************
16
** Includes
17
*****************************************************************************/
18
19
#include <errno.h>
20
#include <
ecl/errors/handlers.hpp
>
21
#include "../../../include/ecl/devices/detail/error_handler.hpp"
22
23
/*****************************************************************************
24
** Namespaces
25
*****************************************************************************/
26
27
namespace
ecl
{
28
namespace
devices {
29
30
/*****************************************************************************
31
** Implementation [Exception Handlers]
32
*****************************************************************************/
33
34
ecl::Error
open_error
() {
35
int
error_result = errno;
36
switch
(error_result) {
37
case
( EINVAL ) :
return
ecl::Error
(
ecl::InvalidArgError
);
38
case
( EACCES ) :
return
ecl::Error
(
ecl::PermissionsError
);
39
case
( EFBIG ) :
case
(EOVERFLOW) :
40
return
ecl::Error
(
ecl::OutOfResourcesError
);
41
case
( EINTR ) :
return
ecl::Error
(
ecl::InterruptedError
);
42
case
( EISDIR ) :
return
ecl::Error
(
ecl::InvalidObjectError
);
43
case
( ELOOP ) :
return
ecl::Error
(
ecl::SystemFailureError
);
44
case
( EMFILE ) :
return
ecl::Error
(
ecl::OutOfResourcesError
);
45
case
( ENFILE ) :
return
ecl::Error
(
ecl::OutOfResourcesError
);
46
case
( ENAMETOOLONG ) :
return
ecl::Error
(
ecl::InvalidArgError
);
47
case
( ENOMEM ) :
return
ecl::Error
(
ecl::MemoryError
);
48
case
( ENOSPC ) :
return
ecl::Error
(
ecl::OutOfResourcesError
);
49
case
( ENOTDIR ):
return
ecl::Error
(
ecl::InvalidObjectError
);
50
case
( EROFS ) :
return
ecl::Error
(
ecl::PermissionsError
);
51
case
( ETXTBSY ):
return
ecl::Error
(
ecl::UsageError
);
52
default :
return
ecl::Error
(
ecl::UnknownError
);
53
}
54
}
55
56
57
ecl::Error
write_error
() {
58
int
error_result = errno;
59
switch
(error_result) {
60
case
( EAGAIN ) :
return
ecl::Error
(
ecl::BlockingError
);
61
case
( EBADF ) :
case
(EINVAL)
62
:
return
ecl::Error
(
ecl::InvalidObjectError
);
63
case
( EFAULT ) :
return
ecl::Error
(
ecl::OutOfRangeError
);
64
case
( EFBIG ) :
return
ecl::Error
(
ecl::MemoryError
);
65
case
( EINTR ) :
return
ecl::Error
(
ecl::InterruptedError
);
66
case
( EIO ) :
return
ecl::Error
(
ecl::SystemFailureError
);
67
case
( ENOSPC ) :
return
ecl::Error
(
ecl::OutOfResourcesError
);
68
case
( EPIPE ) :
return
ecl::Error
(
ecl::PermissionsError
);
69
default :
return
ecl::Error
(
ecl::UnknownError
);
70
}
71
}
72
73
74
ecl::Error
read_error
() {
75
int
error_result = errno;
76
switch
(error_result) {
77
case
( EAGAIN ) :
return
ecl::Error
(
ecl::BlockingError
);
78
case
( EBADF ) :
case
(EINVAL)
79
:
return
ecl::Error
(
ecl::PermissionsError
);
80
case
( EFAULT ) :
return
ecl::Error
(
ecl::OutOfRangeError
);
81
case
( EINTR ) :
return
ecl::Error
(
ecl::InterruptedError
);
82
case
( EIO ) :
return
ecl::Error
(
ecl::SystemFailureError
);
83
case
( EISDIR ) :
return
ecl::Error
(
ecl::InvalidObjectError
);
84
default :
return
ecl::Error
(
ecl::UnknownError
);
85
}
86
}
87
ecl::Error
sync_error
() {
88
int
error_result = errno;
89
switch
(error_result) {
90
case
( EBADF ) :
return
ecl::Error
(
ecl::InvalidArgError
);
91
case
( EIO ) :
return
ecl::Error
(
ecl::CloseError
);
92
case
( EROFS ) :
case
( EINVAL )
93
:
return
ecl::Error
(
ecl::NotSupportedError
);
94
default :
return
ecl::Error
(
ecl::UnknownError
);
95
}
96
}
97
ecl::Error
close_error
() {
98
int
error_result = errno;
99
switch
(error_result) {
100
case
( EBADF ) :
return
ecl::Error
(
ecl::InvalidArgError
);
101
case
( EIO ) :
return
ecl::Error
(
ecl::SystemFailureError
);
102
case
( EINTR ) :
return
ecl::Error
(
ecl::InterruptedError
);
103
default :
return
ecl::Error
(
ecl::UnknownError
);
104
}
105
}
106
107
}
// namespace devices
108
}
// namespace ecl
ecl::UsageError
UsageError
ecl::OutOfResourcesError
OutOfResourcesError
ecl::devices::sync_error
ecl::Error sync_error()
Definition:
error_handler.cpp:99
ecl::devices::close_error
ecl::Error close_error()
Definition:
error_handler.cpp:109
ecl::Error
ecl::SystemFailureError
SystemFailureError
ecl::MemoryError
MemoryError
ecl::InterruptedError
InterruptedError
ecl::InvalidObjectError
InvalidObjectError
ecl::devices::read_error
ecl::Error read_error()
Definition:
error_handler.cpp:86
handlers.hpp
ecl::InvalidArgError
InvalidArgError
ecl::PermissionsError
PermissionsError
ecl::UnknownError
UnknownError
ecl::CloseError
CloseError
ecl::NotSupportedError
NotSupportedError
ecl::devices::write_error
ecl::Error write_error()
Definition:
error_handler.cpp:69
ecl::OutOfRangeError
OutOfRangeError
ecl::BlockingError
BlockingError
ecl
Embedded control libraries.
ecl::devices::open_error
ecl::Error open_error()
Definition:
error_handler.cpp:46
ecl_devices
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:45