I would like to throw exceptions with a meaningful explanation (socket descriptor, process id, network interface index, ...)! I thought using variable arguments works fine, but lately I realized that it's impossible to extend a class to implement other types of exceptions. So I decided to use std :: ostreamstring as an internal buffer to handle formatting ... but it does not compile! I assume this deals with copy constructors. Anyway, here is my piece of code:
class Exception: public std::exception {
public:
Exception(const char *fmt, ...);
Exception(const char *fname,
const char *funcname, int line, const char *fmt, ...);
~Exception() throw();
virtual const char *what() const throw();
protected:
char err_msg_[ERRBUFSIZ];
//std::ostringstream os_;
};
The argumens variable constructor cannot be inherited from! that is why i was thinking about std :: ostringstream! Any recommendations on how to implement this approach?
source
share