Used std::string instead of char and sprintf for constructing an error