mirror of https://github.com/PCSX2/pcsx2.git
gamedb: handle yaml parsing errors properly
This commit is contained in:
parent
bda3835cb1
commit
6920b4e366
|
@ -240,13 +240,12 @@ static std::ifstream getFileStream(std::string path)
|
||||||
|
|
||||||
static void initDatabase()
|
static void initDatabase()
|
||||||
{
|
{
|
||||||
const ryml::Callbacks preserve_callbacks = ryml::get_callbacks();
|
ryml::Callbacks rymlCallbacks = ryml::get_callbacks();
|
||||||
const c4::error_callback_type preserve_c4_callback = c4::get_error_callback();
|
rymlCallbacks.m_error = [](const char* msg, size_t msg_len, ryml::Location loc, void*) {
|
||||||
auto callbacks = ryml::get_callbacks();
|
|
||||||
callbacks.m_error = [](const char* msg, size_t msg_len, ryml::Location loc, void*) {
|
|
||||||
throw std::runtime_error(fmt::format("[YAML] Parsing error at {}:{} (bufpos={}): {}",
|
throw std::runtime_error(fmt::format("[YAML] Parsing error at {}:{} (bufpos={}): {}",
|
||||||
loc.line, loc.col, loc.offset, msg));
|
loc.line, loc.col, loc.offset, msg));
|
||||||
};
|
};
|
||||||
|
ryml::set_callbacks(rymlCallbacks);
|
||||||
c4::set_error_callback([](const char* msg, size_t msg_size) {
|
c4::set_error_callback([](const char* msg, size_t msg_size) {
|
||||||
throw std::runtime_error(fmt::format("[YAML] Internal Parsing error: {}",
|
throw std::runtime_error(fmt::format("[YAML] Internal Parsing error: {}",
|
||||||
msg));
|
msg));
|
||||||
|
@ -296,10 +295,8 @@ static void initDatabase()
|
||||||
catch (const std::exception& e)
|
catch (const std::exception& e)
|
||||||
{
|
{
|
||||||
Console.Error(fmt::format("[GameDB] Error occured when initializing GameDB: {}", e.what()));
|
Console.Error(fmt::format("[GameDB] Error occured when initializing GameDB: {}", e.what()));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
ryml::set_callbacks(preserve_callbacks);
|
ryml::reset_callbacks();
|
||||||
c4::set_error_callback(preserve_c4_callback);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue