bug:connect函数在处理插入已存在连接时的业务逻辑错误
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
// 这是一个异常,当用户尝试插入已存在的连接时抛出
|
||||
|
||||
#ifndef INSERTEXISTEDCONNECTEXCEPTION_H
|
||||
#define INSERTEXISTEDCONNECTEXCEPTION_H
|
||||
#include <exception>
|
||||
#include <string>
|
||||
|
||||
|
||||
class InsertExistedConnectException : public std::exception{
|
||||
private:
|
||||
std::string message;
|
||||
public:
|
||||
InsertExistedConnectException():message("You input id is out of range"){}
|
||||
InsertExistedConnectException(const std::string& msg) : message(msg) {}
|
||||
InsertExistedConnectException(const std::string& msg,int errCode):message(msg+" Err code: "+std::to_string(errCode)){}
|
||||
|
||||
virtual ~InsertExistedConnectException() noexcept {}
|
||||
virtual const char* what() const noexcept override {
|
||||
return message.c_str();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //INSERTEXISTEDCONNECTEXCEPTION_H
|
||||
Reference in New Issue
Block a user