C++代码 常见错误码写法

版权声明: https://blog.csdn.net/dadan1314/article/details/87803797

错误码和错误短语

enum ReturnStatus
{
    STS_ERR_FAILED                = -999,
    STS_ERR_NOT_INITIALIZED       = -998,
    STS_ERR_NOT_ENOUGH_DATA       = -996,
    STS_ERR_NULL_PTR              = -995,
    STS_ERR_INIT                  = -899,
    STS_ERR_END_OF_STREAM         = -895,
    STS_ERR_ALLOC                 = -883,
    STS_ERR_UNSUPPORTED           = -879,
    STS_ERR_INVALID_PARAMS        = -876,
    STS_ERR_FILE_OPEN             = -875,
    STS_ERR_FORMAT                = -874,
    STS_OK                        =  0
};

typedef int Status;

struct CodeStringTable
{
    int         iCode;
    const char *pString;
};

static const CodeStringTable StringOfBaseStatus[] = {
    { STS_OK,                   "Success" },
    { STS_ERR_FAILED,           "General failure" },
    { STS_ERR_NOT_INITIALIZED,  "Object is not initialized" },
    { STS_ERR_NOT_ENOUGH_DATA,  "Not enough input data" },
    { STS_ERR_NULL_PTR,         "Unexpected NULL pointer" },
    { STS_ERR_INIT,             "Failed to initialize object" },
    { STS_ERR_END_OF_STREAM,    "End of stream" },
    { STS_ERR_ALLOC,            "Failed to allocate memory" },
    { STS_ERR_UNSUPPORTED,      "Unsupported parameters/mode" },
    { STS_ERR_INVALID_PARAMS,   "Invalid parameters" },
    { STS_ERR_FILE_OPEN,        "Failed to open file" },
    { STS_ERR_FORMAT,           "Invalid format" },
};

猜你喜欢

转载自blog.csdn.net/dadan1314/article/details/87803797