mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-12 06:21:50 +00:00
add filename info to content unit loading
This commit is contained in:
parent
900f118f94
commit
e0bf82a71e
2 changed files with 22 additions and 4 deletions
|
|
@ -178,7 +178,16 @@ void ContentUnitLoader<DefT>::loadUnit(
|
||||||
) {
|
) {
|
||||||
auto folder = pack.folder;
|
auto folder = pack.folder;
|
||||||
auto configFile = folder / (defsDir + "/" + name + ".json");
|
auto configFile = folder / (defsDir + "/" + name + ".json");
|
||||||
if (io::exists(configFile)) loadUnit(def, full, configFile);
|
if (io::exists(configFile)) {
|
||||||
|
try {
|
||||||
|
loadUnit(def, full, configFile);
|
||||||
|
} catch (const std::runtime_error& err) {
|
||||||
|
throw std::runtime_error(
|
||||||
|
"file " + util::quote(configFile.string()) + ": " +
|
||||||
|
std::string(err.what())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLoader::loadBlockMaterial(
|
void ContentLoader::loadBlockMaterial(
|
||||||
|
|
|
||||||
|
|
@ -173,8 +173,12 @@ bool io::write_binary_json(
|
||||||
}
|
}
|
||||||
|
|
||||||
dv::value io::read_json(const path& filename) {
|
dv::value io::read_json(const path& filename) {
|
||||||
std::string text = io::read_string(filename);
|
auto text = io::read_string(filename);
|
||||||
return json::parse(filename.string(), text);
|
try {
|
||||||
|
return json::parse(filename.string(), text);
|
||||||
|
} catch (const parsing_error& err) {
|
||||||
|
throw err.toRuntimeError();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dv::value io::read_binary_json(const path& file) {
|
dv::value io::read_binary_json(const path& file) {
|
||||||
|
|
@ -184,7 +188,12 @@ dv::value io::read_binary_json(const path& file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
dv::value io::read_toml(const path& file) {
|
dv::value io::read_toml(const path& file) {
|
||||||
return toml::parse(file.string(), io::read_string(file));
|
auto text = io::read_string(file);
|
||||||
|
try {
|
||||||
|
return toml::parse(file.string(), text);
|
||||||
|
} catch (const parsing_error& err) {
|
||||||
|
throw err.toRuntimeError();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> io::read_list(const io::path& filename) {
|
std::vector<std::string> io::read_list(const io::path& filename) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue