Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/psx/mednadisc/error.h
2 views
1
#ifndef __MDFN_ERROR_H
2
#define __MDFN_ERROR_H
3
4
#include <errno.h>
5
#include <string.h>
6
#include <exception>
7
8
#ifdef __cplusplus
9
10
class ErrnoHolder;
11
class MDFN_Error : public std::exception
12
{
13
public:
14
15
MDFN_Error() noexcept;
16
17
MDFN_Error(int errno_code_new, const char *format, ...) noexcept MDFN_FORMATSTR(gnu_printf, 3, 4);
18
MDFN_Error(const ErrnoHolder &enh);
19
20
~MDFN_Error() noexcept;
21
22
MDFN_Error(const MDFN_Error &ze_error) noexcept;
23
MDFN_Error & operator=(const MDFN_Error &ze_error) noexcept;
24
25
virtual const char *what(void) const noexcept;
26
int GetErrno(void) const noexcept;
27
28
private:
29
30
int errno_code;
31
char *error_message;
32
};
33
34
class ErrnoHolder
35
{
36
public:
37
38
ErrnoHolder()
39
{
40
//SetErrno(0);
41
local_errno = 0;
42
local_strerror[0] = 0;
43
}
44
45
ErrnoHolder(int the_errno)
46
{
47
SetErrno(the_errno);
48
}
49
50
inline int Errno(void) const
51
{
52
return(local_errno);
53
}
54
55
const char *StrError(void) const
56
{
57
return(local_strerror);
58
}
59
60
void operator=(int the_errno)
61
{
62
SetErrno(the_errno);
63
}
64
65
private:
66
67
void SetErrno(int the_errno);
68
69
int local_errno;
70
char local_strerror[256];
71
};
72
73
#endif
74
75
#endif
76
77