inital commit
[c11concurrency-benchmarks.git] / mabain / src / error.h
1 /**
2  * Copyright (C) 2017 Cisco Inc.
3  *
4  * This program is free software: you can redistribute it and/or  modify
5  * it under the terms of the GNU General Public License, version 2,
6  * as published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15  */
16
17 // @author Changxue Deng <chadeng@cisco.com>
18
19 #ifndef __MBERROR_H__
20 #define __MBERROR_H__
21
22 #undef TRY_AGAIN
23
24 namespace mabain {
25
26 // mabain errors
27 class MBError
28 {
29 public:
30     enum mb_error
31     {
32         SUCCESS = 0,
33         NO_MEMORY = 1,
34         OUT_OF_BOUND = 2,
35         INVALID_ARG = 3,
36         NOT_INITIALIZED = 4,
37         NOT_EXIST = 5,
38         IN_DICT = 6,
39         MMAP_FAILED = 7,
40         NOT_ALLOWED = 8,
41         OPEN_FAILURE = 9,
42         WRITE_ERROR = 10,
43         READ_ERROR = 11,
44         INVALID_SIZE = 12,
45         TRY_AGAIN = 13,
46         ALLOCATION_ERROR = 14,
47         MUTEX_ERROR = 15,
48         UNKNOWN_ERROR = 16,
49         WRITER_EXIST = 17,
50         NO_RESOURCE = 18,
51         DB_CLOSED = 19,
52         BUFFER_LOST = 20,
53         THREAD_FAILED = 21,
54         RC_SKIPPED = 22,
55         VERSION_MISMATCH = 23,
56
57         // NO_DB should be the last enum.
58         NO_DB
59     };
60
61     static const int MAX_ERROR_CODE;
62     static const char* error_str[];
63     static const char* get_error_str(int err);
64 };
65
66 }
67
68 #endif