You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

52 lines
1.3 KiB

#pragma once
#include <exception>
#include <string>
namespace std _GLIBCXX_VISIBILITY(default) {
class zexception : public exception {
string m_ecodeinfo = "";
int32_t m_ecode = 0;
public:
/** Takes a character string describing the error. */
explicit zexception(int32_t ecode, const string& __arg) {
m_ecodeinfo = __arg;
m_ecode = ecode;
}
const char* what() const noexcept override { return m_ecodeinfo.c_str(); }
int32_t ecode() const noexcept { return m_ecode; }
};
typedef enum {
ke_ok = 10000 + 0,
ke_error = 10000 + 1,
ke_channel_is_close = 10000 + 2,
ke_invalid_param = 10000 + 3,
ke_invalid_packet_format = 10000 + 4,
ke_overtime = 10000 + 5,
ke_parse_config_file_fail = 10000 + 6,
} zecode_t;
static inline const char* zecode2str(zecode_t ecode) {
switch (ecode) {
case ke_ok:
return "success";
case ke_channel_is_close:
return "channel_is_close";
case ke_invalid_param:
return "invalid_param";
case ke_invalid_packet_format:
return "invalid_packet_format";
case ke_overtime:
return "overtime";
case ke_parse_config_file_fail:
return "parse_config_file_fail";
default:
return "unkown error";
}
}
} // namespace std _GLIBCXX_VISIBILITY(default)