-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathix_error.cpp
More file actions
50 lines (47 loc) · 1.38 KB
/
Copy pathix_error.cpp
File metadata and controls
50 lines (47 loc) · 1.38 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
#include "ix_error.h"
#include <errno.h>
#include <stdio.h>
#include <iostream>
using namespace std;
static const char *IXWarnMsg[] = {
"key was not found in btree",
"key attribute size is too small(<=0) or too big for a page",
"key,rid already exists in index",
"key,rid combination does not exist in index",
};
static const char *IXErrorMsg[] = {
"entry is too big",
"error is in the PF component",
"Index page with btree node is no longer valid",
"Index file creation failed",
"attempt to open already open file handle",
"bad parameters specified to IX open file handle",
"file is not open",
"Bad RID - invalid page num or slot num",
"Bad Key - null or invalid",
"end of file",
};
//
// IX_PrintError - 根据返回码,打印相应的出错信息
//
void IXPrintError(RC rc)
{
// 检查返回码在可控的范围之内
if (rc >= START_IX_WARN && rc <= IX_LASTWARN)
cerr << "IX warning: " << IXWarnMsg[rc - START_IX_WARN] << "\n";
// Error codes are negative, so invert everything
else if ((-rc >= -START_IX_ERR) && -rc <= -IX_LASTERROR)
{
cerr << "IX error: " << IXErrorMsg[-rc + START_IX_ERR] << "\n";
}
else if (rc == 0)
cerr << "IX_PrintError called with return code of 0\n";
else
{
// Print error
cerr << "rc was " << rc << endl;
cerr << "START_IX_ERR was " << START_IX_ERR << endl;
cerr << "IX_LASTERROR was " << IX_LASTERROR << endl;
cerr << "IX error: " << rc << " is out of bounds\n";
}
}