fix: throw; al call site, no a l'helper
This commit is contained in:
@@ -362,13 +362,13 @@ namespace Resource {
|
|||||||
return rooms_;
|
return rooms_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper para lanzar errores de carga con formato consistente
|
// Helper para registrar errores de carga con formato consistente.
|
||||||
[[noreturn]] void Cache::throwLoadError(const std::string& asset_type, const std::string& file_path, const std::exception& e) { // NOLINT(readability-convert-member-functions-to-static)
|
// El rethrow es responsabilitat del catch que crida la funció.
|
||||||
|
void Cache::logLoadError(const std::string& asset_type, const std::string& file_path, const std::exception& e) { // NOLINT(readability-convert-member-functions-to-static)
|
||||||
std::cerr << "\n[ ERROR ] Failed to load " << asset_type << ": " << getFileName(file_path) << '\n';
|
std::cerr << "\n[ ERROR ] Failed to load " << asset_type << ": " << getFileName(file_path) << '\n';
|
||||||
std::cerr << "[ ERROR ] Path: " << file_path << '\n';
|
std::cerr << "[ ERROR ] Path: " << file_path << '\n';
|
||||||
std::cerr << "[ ERROR ] Reason: " << e.what() << '\n';
|
std::cerr << "[ ERROR ] Reason: " << e.what() << '\n';
|
||||||
std::cerr << "[ ERROR ] Check config/assets.yaml configuration\n";
|
std::cerr << "[ ERROR ] Check config/assets.yaml configuration\n";
|
||||||
throw;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lista fija de text objects. Compartida entre createText() y createOneText(i).
|
// Lista fija de text objects. Compartida entre createText() y createOneText(i).
|
||||||
@@ -415,7 +415,8 @@ namespace Resource {
|
|||||||
printWithDots("Sound : ", name, "[ LOADED ]");
|
printWithDots("Sound : ", name, "[ LOADED ]");
|
||||||
updateLoadingProgress();
|
updateLoadingProgress();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
throwLoadError("SOUND", l, e);
|
logLoadError("SOUND", l, e);
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -442,7 +443,8 @@ namespace Resource {
|
|||||||
printWithDots("Music : ", name, "[ LOADED ]");
|
printWithDots("Music : ", name, "[ LOADED ]");
|
||||||
updateLoadingProgress();
|
updateLoadingProgress();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
throwLoadError("MUSIC", l, e);
|
logLoadError("MUSIC", l, e);
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,7 +458,8 @@ namespace Resource {
|
|||||||
surfaces_.back().surface->setTransparentColor(0);
|
surfaces_.back().surface->setTransparentColor(0);
|
||||||
updateLoadingProgress();
|
updateLoadingProgress();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
throwLoadError("BITMAP", l, e);
|
logLoadError("BITMAP", l, e);
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,7 +483,8 @@ namespace Resource {
|
|||||||
palettes_.emplace_back(ResourcePalette{.name = name, .palette = readPalFile(l)});
|
palettes_.emplace_back(ResourcePalette{.name = name, .palette = readPalFile(l)});
|
||||||
updateLoadingProgress();
|
updateLoadingProgress();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
throwLoadError("PALETTE", l, e);
|
logLoadError("PALETTE", l, e);
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,7 +497,8 @@ namespace Resource {
|
|||||||
text_files_.emplace_back(TextFileResource{.name = name, .text_file = Text::loadTextFile(l)});
|
text_files_.emplace_back(TextFileResource{.name = name, .text_file = Text::loadTextFile(l)});
|
||||||
updateLoadingProgress();
|
updateLoadingProgress();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
throwLoadError("FONT", l, e);
|
logLoadError("FONT", l, e);
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -513,7 +518,8 @@ namespace Resource {
|
|||||||
printWithDots("Animation : ", name, "[ LOADED ]");
|
printWithDots("Animation : ", name, "[ LOADED ]");
|
||||||
updateLoadingProgress();
|
updateLoadingProgress();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
throwLoadError("ANIMATION", l, e);
|
logLoadError("ANIMATION", l, e);
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -527,7 +533,8 @@ namespace Resource {
|
|||||||
printWithDots("Room : ", name, "[ LOADED ]");
|
printWithDots("Room : ", name, "[ LOADED ]");
|
||||||
updateLoadingProgress();
|
updateLoadingProgress();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
throwLoadError("ROOM", l, e);
|
logLoadError("ROOM", l, e);
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ namespace Resource {
|
|||||||
void setCurrentLoading(const std::string& name); // Desa el nom del recurs en curs
|
void setCurrentLoading(const std::string& name); // Desa el nom del recurs en curs
|
||||||
|
|
||||||
// Helper para mensajes de error de carga
|
// Helper para mensajes de error de carga
|
||||||
[[noreturn]] static void throwLoadError(const std::string& asset_type, const std::string& file_path, const std::exception& e);
|
static void logLoadError(const std::string& asset_type, const std::string& file_path, const std::exception& e);
|
||||||
|
|
||||||
// Constructor y destructor
|
// Constructor y destructor
|
||||||
Cache();
|
Cache();
|
||||||
|
|||||||
Reference in New Issue
Block a user