// 这是一个异常,当用户试图连接图中的两个相同节点时抛出 #ifndef SAMENODECONNECTEXCEPTION_H #define SAMENODECONNECTEXCEPTION_H #include #include class SameNodeConnectException : public std::exception{ private: std::string message; public: SameNodeConnectException():message("Don't connect same node"){} SameNodeConnectException(const std::string& msg) : message(msg) {} SameNodeConnectException(const std::string& msg,int errCode):message(msg+"Err code: "+std::to_string(errCode)){} virtual ~SameNodeConnectException() noexcept {} virtual const char* what() const noexcept override { return message.c_str(); } }; #endif //SAMENODECONNECTEXCEPTION_H