-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathErrors.hpp
38 lines (32 loc) · 994 Bytes
/
Errors.hpp
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
#pragma once
#include <string>
#include <inttypes.h>
namespace NSErr {
/** all codes of errors in class Error **/
enum class ErrEnum : uint16_t {
OVERFLOW = 1,
EMPTY,
RANGE_OUT
};
/** ejected object in try catch syntax-construction **/
class Error {
public:
explicit Error(const std::string & message, const ErrEnum code)
: _message(message), _code(code)
{}
explicit Error(const char * message, const ErrEnum code)
: _message(std::string(message)), _code(code)
{}
std::string message() const { return _message; }
ErrEnum code() const { return _code; }
Error() = delete;
Error(const Error & err) = delete;
Error(Error && err) = default;
Error & operator=(const Error & err) = delete;
Error & operator=(Error && err) = delete;
~Error() = default;
private:
std::string _message;
ErrEnum _code;
};
}