1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-19 00:17:56 +02:00

Throw std::runtime_exception instead of a pointer to new one

cf. https://isocpp.org/wiki/faq/exceptions#what-to-throw
This commit is contained in:
Michał Janiszewski
2018-10-31 07:27:54 +01:00
parent 2a282c9a8e
commit 0ff2e1180d
5 changed files with 20 additions and 20 deletions

View File

@ -84,7 +84,7 @@ static JsonNode getFromArchive(CZipLoader & archive, const std::string & archive
ResourceID resource(archiveFilename, EResType::TEXT);
if(!archive.existsResource(resource))
throw new std::runtime_error(archiveFilename+" not found");
throw std::runtime_error(archiveFilename+" not found");
auto data = archive.load(resource)->readAll();
@ -99,7 +99,7 @@ static void addToArchive(CZipSaver & saver, const JsonNode & data, const std::st
std::unique_ptr<COutputStream> stream = saver.addFile(filename);
if(stream->write((const ui8*)s.c_str(), s.size()) != s.size())
throw new std::runtime_error("CMapSaverJson::saveHeader() zip compression failed.");
throw std::runtime_error("CMapSaverJson::saveHeader() zip compression failed.");
}
static std::unique_ptr<CMap> loadOriginal(const JsonNode & header, const JsonNode & objects, const JsonNode & surface, const JsonNode & underground)