diff --git a/errorcode.cpp b/errorcode.cpp new file mode 100644 index 0000000..30b567b --- /dev/null +++ b/errorcode.cpp @@ -0,0 +1,77 @@ +#include "errorcode.hpp" + +#define ERR2STR(code) \ + case code: \ + return #code; +namespace iflytop { +namespace err { +const char* error2str(int32_t code) { + switch (code) { + ERR2STR(ksucc); + ERR2STR(kfail); + ERR2STR(ksys_error); + ERR2STR(ksys_create_file_error); + ERR2STR(ksys_create_dir_error); + ERR2STR(ksys_open_file_error); + ERR2STR(ksys_open_dir_error); + ERR2STR(ksys_read_file_error); + ERR2STR(ksys_write_file_error); + ERR2STR(ksys_close_file_error); + ERR2STR(ksys_close_dir_error); + ERR2STR(ksys_delete_file_error); + ERR2STR(ksys_delete_dir_error); + ERR2STR(ksys_copy_file_error); + ERR2STR(kce_device_not_zero); + ERR2STR(kce_over_temperature); + ERR2STR(kce_over_voltage); + ERR2STR(kce_param_out_of_range); + ERR2STR(kce_not_found_zero_point); + ERR2STR(kce_not_found_x_zero_point); + ERR2STR(kce_not_found_y_zero_point); + ERR2STR(kce_x_leave_away_zero_point_fail); + ERR2STR(kce_y_leave_away_zero_point_fail); + ERR2STR(kce_operation_not_support); + ERR2STR(kce_device_is_busy); + ERR2STR(kce_device_is_offline); + ERR2STR(kce_break_by_user); + ERR2STR(kce_overtime); + ERR2STR(kce_noack); + ERR2STR(kce_errorack); + ERR2STR(kce_device_offline); + ERR2STR(kce_parse_json_err); + ERR2STR(kce_subdevice_overtime); + ERR2STR(kdbe_user_not_exist); + ERR2STR(kdbe_catch_exception); + ERR2STR(kharde_unfound); + ERR2STR(kre_catch_exception); + ERR2STR(kinteraction_error_passwd_error); + ERR2STR(kinteraction_error_user_not_exist); + ERR2STR(kce_buffer_not_enough); + ERR2STR(kSMTP2_NoError); + ERR2STR(kSMTP2_InitFail); + ERR2STR(kSMTP2_InvalidCmd); + ERR2STR(kSMTP2_InvalidArg); + ERR2STR(kSMTP2_PressureSensorError); + ERR2STR(kSMTP2_OverPressure); + ERR2STR(kSMTP2_LLDError); + ERR2STR(kSMTP2_DeviceNotInit); + ERR2STR(kSMTP2_TipPopError); + ERR2STR(kSMTP2_PumpOverload); + ERR2STR(kSMTP2_TipDrop); + ERR2STR(kSMTP2_CanBusError); + ERR2STR(kSMTP2_InvalidChecksum); + ERR2STR(kSMTP2_EEPROMError); + ERR2STR(kSMTP2_CmdBufferEmpty); + ERR2STR(kSMTP2_CmdBufferOverflow); + ERR2STR(kSMTP2_TipBlock); + ERR2STR(kSMTP2_AirSuction); + ERR2STR(kSMTP2_Bubble); + ERR2STR(kSMTP2_VolumeError); + ERR2STR(kSMTP2_TipAlreadyLoad); + ERR2STR(kSMTP2_TipLoadFail); + default: + break; + } +} +} // namespace err +} // namespace iflytop \ No newline at end of file diff --git a/errorcode.hpp b/errorcode.hpp index 3a427d0..d1a0e1c 100644 --- a/errorcode.hpp +++ b/errorcode.hpp @@ -1,4 +1,5 @@ #pragma once +#include namespace iflytop { namespace err { @@ -83,5 +84,8 @@ typedef enum { kSMTP2_TipLoadFail = ERROR_CODE(20000, 21), } error_t; + + const char* error2str(int32_t code); + } // namespace err } // namespace iflytop \ No newline at end of file