This repository was archived by the owner on Apr 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathError.h
More file actions
75 lines (54 loc) · 1.3 KB
/
Error.h
File metadata and controls
75 lines (54 loc) · 1.3 KB
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
68
69
70
71
72
73
74
75
/*
* Error.h
*
* Created on: 2011-5-14
* Author: simophin
*/
#ifndef ERROR_H_
#define ERROR_H_
#include "RString.h"
#include "utils/SharedPtr.hpp"
#include <iostream>
typedef int syserrno_t;
class Error {
public:
enum Type {
ERR_SUCCESS,
ERR_UNKNOWN,
ERR_SYS_UNKNOWN,
ERR_STATE,
ERR_TIMEOUT,
ERR_INVALID,
ERR_ADDRINUSE
};
Error (Type t = ERR_SUCCESS);
explicit Error (Type t, const String &str);
explicit Error (syserrno_t sys);
explicit Error (syserrno_t sys, const String &str);
virtual ~Error ();
Type getErrorType() const;
void setErrorType (Type t);
void setErrorType (Type t, const String &str);
String getErrorString() const;
void setErrorString (const String &str);
syserrno_t getSystemError () const;
void setSystemError (syserrno_t);
void setSystemError (syserrno_t, const String &);
bool isSuccess () const;
inline bool isError() const {
return !isSuccess();
}
String toString() const;
static Error fromString(const String &,bool *ok = NULL);
friend std::ostream& operator <<(std::ostream &os,const Error &obj);
class SystemMap {
public:
syserrno_t system;
Type type;
const char * message;
};
private:
class Impl;
Utils::SharedPtr<Impl> d;
};
#endif /* ERROR_H_ */