/*
 * Copyright (c) 2022 Huawei Technologies Co.,Ltd.
 *
 * GR is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *
 *          http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 * -------------------------------------------------------------------------
 *
 * gr_errno.h
 *
 *
 * IDENTIFICATION
 *    src/interface/gr_errno.h
 *
 * -------------------------------------------------------------------------
 */

#ifndef __GR_ERRNO_H__
#define __GR_ERRNO_H__

#ifdef __cplusplus
extern "C" {
#endif

#define GR_SUCCESS 0
#define GR_ERROR (-1)

/** 1.GR range [2000, 2500] *
 *  2.ERR_GR_SUBMODEL_ACTION_DETAIL, _DETAIL is optional which indicates the error cause.
 */
#define ERR_GR_FLOOR 2000

// file error [2130, 2230)
#define ERR_GR_FILE_SEEK 2130
#define ERR_GR_FILE_REMOVE 2140
#define ERR_GR_FILE_REMOVE_OPENING 2141
#define ERR_GR_FILE_REMOVE_SYSTEM 2142
#define ERR_GR_FILE_RENAME 2150
#define ERR_GR_FILE_RENAME_DIFF_VG 2151
#define ERR_GR_FILE_RENAME_EXIST 2152
#define ERR_GR_FILE_RENAME_OPENING_REMOTE 2153
#define ERR_GR_FILE_CLOSE 2160
#define ERR_GR_FILE_CREATE 2170
#define ERR_GR_FILE_RDWR 2180
#define ERR_GR_FILE_RDWR_INSUFF_PER 2181
#define ERR_GR_FILE_NOT_EXIST 2190
#define ERR_GR_FILE_OPENING_REMOTE 2191
#define ERR_GR_FILE_TYPE_MISMATCH 2192
#define ERR_GR_FILE_PATH_ILL 2193
#define ERR_GR_FILE_INVALID_SIZE 2194
#define ERR_GR_FILE_INVALID_FLAG 2195
#define ERR_GR_FILE_INVALID_EXPIRE_TIME 2196

// dir error [2230, 2280)
#define ERR_GR_DIR_REMOVE 2230
#define ERR_GR_DIR_REMOVE_NOT_EMPTY 2231
#define ERR_GR_DIR_CREATE 2240
#define ERR_GR_DIR_CREATE_DUPLICATED 2241
#define ERR_GR_DIR_NOT_EXIST 2242

// link error [2280, 2300)
#define ERR_GR_LINK_READ 2280
#define ERR_GR_LINK_READ_NOT_LINK 2281
#define ERR_GR_LINK_CREATE 2290

// config error [2300, 2320)
#define ERR_GR_CONFIG_FILE_OVERSIZED 2300
#define ERR_GR_CONFIG_LOAD 2301
#define ERR_GR_CONFIG_LINE_OVERLONG 2302
#define ERR_GR_CONFIG_NOT_EXIST 2303

// redo error [2320, 2350)
#define ERR_GR_REDO_ILL 2320

// Basic Data Structure error [2350, 2400)
#define ERR_GR_OAMAP_INSERT 2350
#define ERR_GR_OAMAP_INSERT_DUP_KEY 2351
#define ERR_GR_OAMAP_FETCH 2352
#define ERR_GR_SESSION_INVALID_ID 2390
#define ERR_GR_SESSION_CREATE 2391
#define ERR_GR_SESSION_EXTEND 2392

// other error [2400, 2500)
#define ERR_GR_INVALID_PARAM 2400
#define ERR_GR_NO_SPACE 2401
#define ERR_GR_ENV_NOT_INITIALIZED 2402
#define ERR_GR_CLI_EXEC_FAIL 2403
#define ERR_GR_FNODE_CHECK 2404
#define ERR_GR_LOCK_TIMEOUT 2405
#define ERR_GR_SERVER_IS_DOWN 2406
#define ERR_GR_CHECK_SIZE 2407
#define ERR_GR_MES_ILL 2408
#define ERR_GR_STRING_TOO_LONG 2409
#define ERR_GR_TCP_TIMEOUT_REMAIN 2410
#define ERR_GR_TCP_INVALID_URL 2411
#define ERR_GR_RECV_MSG_FAILED 2412
#define ERR_GR_INIT_LOGGER_FAILED 2414
#define ERR_GR_ALLOC_MEMORY 2415
#define ERR_GR_INVALID_ID 2416
#define ERR_GR_PROCESS_REMOTE 2417
#define ERR_GR_CONNECT_FAILED 2418
#define ERR_GR_VERSION_NOT_MATCH 2419
#define ERR_GR_INVALID_BLOCK_TYPE 2420
#define ERR_GR_SERVER_REBOOT 2421
#define ERR_GR_UNSUPPORTED_CMD 2422
#define ERR_GR_FILE_SYSTEM_ERROR 2423
#define ERR_GR_CONNECTION_CLOSED 2424
#define ERR_GR_MEM_CMP_FAILED 2425
#define ERR_GR_READONLY 2426
#define ERR_GR_WHITELIST_INVALID 2427
#define ERR_GR_CALL_SERVER_FAILED 2428
#define ERR_GR_HASH_AUTH_FAILED 2429
#define ERR_GR_NOT_MASTER 2430

#define ERR_GR_MASTER_CHANGE 2498
#define ERR_GR_RECOVER_CAUSE_BREAK 2499

#define ERR_GR_CEIL 2500

#ifdef __cplusplus
}
#endif

#endif