From 2a31a8676fa4377ed920645da87880541e2467a0 Mon Sep 17 00:00:00 2001 From: kiritow <1362050620@qq.com> Date: Mon, 20 Nov 2017 09:07:58 +0800 Subject: [PATCH] Add errcode header --- jsonfail.cpp | 28 ++++++++++++++++++++++++++++ jsonfail.h | 13 +++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 jsonfail.cpp create mode 100644 jsonfail.h diff --git a/jsonfail.cpp b/jsonfail.cpp new file mode 100644 index 0000000..4e604a4 --- /dev/null +++ b/jsonfail.cpp @@ -0,0 +1,28 @@ +#include "jsonfail.h" + +const char* GetErrMsg(int errcode) +{ + switch(errcode) + { + case err_need_login: + return "Please login first"; + case err_method_not_supported: + return "Request Method not supported"; + case err_missing_parameter: + return "Missing Parameter"; + case err_config: + return "Failed to read configure"; + case err_connect: + return "Failed to connect DB"; + case err_sql: + return "Failed to execute SQL"; + case err_sql_logic: + return "SQL Logical Error"; + case err_permission_denied: + return "Permission denied"; + case err_data: + return "Data Error"; + default: + return "General error"; + } +} diff --git a/jsonfail.h b/jsonfail.h new file mode 100644 index 0000000..9b21119 --- /dev/null +++ b/jsonfail.h @@ -0,0 +1,13 @@ +#pragma once + +#define err_need_login 1 +#define err_method_not_supported 2 +#define err_missing_parameter 3 +#define err_config 4 +#define err_connect 5 +#define err_sql 6 +#define err_sql_logic 7 +#define err_permission_denied 8 +#define err_data 9 + +const char* GetErrMsg(int errcode);