📄 error.h
字号:
#ifndef _ERROR_H_
#define _ERROR_H_
#define ERROR_STRING 1000
#define ILLEGAL_INPUT 1001
#define FIELD_NUM_EXCEED 1002
#define IN_TYPE_ERROR 1003
#define OUT_TYPE_ERROR 1004
#define IN_VALUE_ERROR 1005
#define OUT_VALUE_ERROR 1006
#define TYPE_MATCH_ERROR 1007
#define ENTRY_RANGE_ERROR 1008
#define UNKNOWN_ID 1009
#define SYNTAX_ERROR 1010
#define FILE_OPEN_ERROR 1011
#define FILE_CREATE_ERROR 1012
#define ERROR_RELATION 1013
#define ERROR_BUCKET_REMOVE 1014
#define ERROR_BPLUS_CREATE 1015
#define ERROR_BPLUS_INSERT 1016
#define ERROR_BPLUS_REMOVE 1017
#define ERROR_STACK 1018
#define ERROR_INDEX_LIMIT 1019
#define ERROR_INDEX_EXIST 1020
#define ERROR_INDEX_NOT_EXIST 1021
#define ERROR_AUTHOR 1022
#define ERROR_FILE_CORRUPTED 1023
#define ERROR_PROFILE 1024
#define ERROR_CHANGE_CODE 1025
#define FATAL_ERROR 2000
class Error
{
public:
Error( int id = FATAL_ERROR, int line = 0, const CString& descrip = _T("") ) :
m_ErrType( id ), m_iLine( line ), m_Descrip( descrip ){}
int m_ErrType;
int m_iLine;
CString m_Descrip;
inline int GetErrLine()
{
return m_iLine;
}
CString GetErrStr()
{
CString str;
switch( m_ErrType )
{
case ERROR_STRING:
str.Format( "Error %d : Can't meet string \"%s\" \'s corresponding \" \' \". \n\tSee line %d.",
m_ErrType, m_Descrip, m_iLine );
break;
case ILLEGAL_INPUT:
str.Format( "Error %d : Illegal input : %s. \n\tSee line %d.",
m_ErrType, m_Descrip, m_iLine );
break;
case FIELD_NUM_EXCEED:
str.Format( "Error %d : Max items ( %d ) in the table defined.",
m_ErrType, m_iLine );
break;
case IN_TYPE_ERROR:
str.Format( "Fatal Error %d : Input type ID %d is not defined.",
m_ErrType, (UINT)m_iLine );
break;
case OUT_TYPE_ERROR:
str.Format( "Fatal Error %d : Output type ID %d is not defined.",
m_ErrType, (UINT)m_iLine );
break;
case IN_VALUE_ERROR:
str.Format( "Fatal Error %d : String \"%s\" can't be accessed.",
m_ErrType, m_Descrip );
break;
case OUT_VALUE_ERROR:
str.Format( "Fatal Error %d : String \"%s\" is too long to be accessed.",
m_ErrType, m_Descrip );
break;
case TYPE_MATCH_ERROR:
str.Format( "Error %d : Types of the two components are not matched.",
m_ErrType );
break;
case ENTRY_RANGE_ERROR:
str.Format( "Error %d : The entry attributes range from 0 to %d.",
m_ErrType, m_iLine );
break;
case UNKNOWN_ID:
str.Format( "Error %d : Unknown command indentifier : %s.",
m_ErrType, m_Descrip );
break;
case SYNTAX_ERROR:
str.Format( "Error %d : Syntax error. See around string \"%s\".",
m_ErrType, m_Descrip );
break;
case FILE_OPEN_ERROR:
str.Format( "Fatal Error %d : File \"%s\" can't be opened.",
m_ErrType, m_Descrip );
break;
case FILE_CREATE_ERROR:
str.Format( "Fatal Error %d : File \"%s\" can't be created.",
m_ErrType, m_Descrip );
break;
case ERROR_RELATION:
str.Format( "Error %d : %s is not an attribute name of the relation.",
m_ErrType, m_Descrip );
break;
case ERROR_BUCKET_REMOVE:
str.Format( "Error %d : An key pointer %d is not found in the bucket, cannot be removed.",
m_ErrType, m_iLine );
break;
case ERROR_BPLUS_CREATE:
str.Format( "Error %d : An error occurs when creating the B+ Tree.\n\tMaybe the entry length is too huge.",
m_ErrType, m_iLine );
break;
case ERROR_BPLUS_INSERT:
str.Format( "Error %d : An error occurs when insert a node into the B+ Tree.\n\tMaybe it is a unique index.",
m_ErrType );
break;
case ERROR_BPLUS_REMOVE:
str.Format( "Error %d : An error occurs when delete a node in the B+ Tree.",
m_ErrType );
break;
case ERROR_STACK:
str.Format( "Error %d : The stack is empty, cannot pop again.",
m_ErrType );
break;
case ERROR_INDEX_LIMIT:
str.Format( "Error %d : There have existed %d indices of the table which have reached the index num limit.",
m_ErrType, m_iLine );
break;
case ERROR_INDEX_EXIST:
str.Format( "Error %d : The index \"%s.bpt\" has already existed which cannot be created again.",
m_ErrType, m_Descrip );
break;
case ERROR_INDEX_NOT_EXIST:
str.Format( "Error %d : The index \"%s.bpt\" is not existed so that it cannot be removed.",
m_ErrType, m_Descrip );
break;
case ERROR_AUTHOR:
str.Format( "Error %d : You are not authorized to create, update or drop table or index!",
m_ErrType );
break;
case ERROR_FILE_CORRUPTED:
str.Format( "Error %d : File corrupted.",
m_ErrType );
break;
case ERROR_PROFILE:
str.Format( "Error %d : User File corrupted.",
m_ErrType );
break;
case ERROR_CHANGE_CODE:
str.Format( "Error %d : An file error occurs when saving the user profile.",
m_ErrType );
break;
default:
str.Format( "Fatal Error %d : Unexpected error.", m_ErrType );
}
return str;
}
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -