Improved error handling of gta_data_service. (#411)

Fixed an issue where the game crashes when throwing invalid json format exception.
This commit is contained in:
aa15032261
2022-08-13 19:29:33 +08:00
committed by GitHub
parent fc403483f7
commit 454413be30
2 changed files with 17 additions and 16 deletions

View File

@ -43,7 +43,6 @@ namespace big
g_gta_data_service = nullptr;
}
const vehicle_item& gta_data_service::find_vehicle_by_hash(Hash hash)
{
int idx = -1;
@ -168,11 +167,8 @@ namespace big
try
{
std::ofstream file_ofstream(file_path, std::ios::binary | std::ios::trunc);
file_ofstream << "";
std::ofstream file_etag_ofstream(etag_path, std::ios::binary | std::ios::trunc);
file_etag_ofstream << "";
std::filesystem::remove(file_to_load.get_path());
std::filesystem::remove(file_etag.get_path());
}
catch (...) { }
}
@ -197,7 +193,7 @@ namespace big
if (!all_vehicles.is_array())
{
throw "Invalid json format.";
throw std::exception("Invalid json format.");
}
m_vehicle_class_arr.clear();
@ -250,7 +246,7 @@ namespace big
if (!all_peds.is_array())
{
throw "Invalid json format.";
throw std::exception("Invalid json format.");
}
m_ped_type_arr.clear();
@ -301,7 +297,7 @@ namespace big
if (!all_weapons.is_array())
{
throw "Invalid json format.";
throw std::exception("Invalid json format.");
}
m_weapon_type_arr.clear();