@@ -1366,7 +1366,9 @@ No overload found for function 'UnregisterHook'.
13661366 Unreal::UFunction* unreal_function = Unreal::UObjectGlobals::StaticFindObject<Unreal::UFunction*>(nullptr , nullptr , function_name_no_prefix);
13671367 if (!unreal_function)
13681368 {
1369- lua.throw_error (" Tried to unregister a hook with Lua function 'UnregisterHook' but no UFunction with the specified name was found." );
1369+ lua.throw_error (std::format (" Tried to unregister a hook with Lua function 'UnregisterHook' but no UFunction with the specified name "
1370+ " was found.\n >FunctionName: {}" ,
1371+ to_string (function_name_no_prefix)));
13701372 }
13711373
13721374 if (!lua.is_integer ())
@@ -1383,12 +1385,16 @@ No overload found for function 'UnregisterHook'.
13831385
13841386 if (pre_id > std::numeric_limits<int32_t >::max ())
13851387 {
1386- lua.throw_error (" Tried to unregister a hook with Lua function 'UnregisterHook' but the PreCallbackId supplied was too large (>int32)" );
1388+ lua.throw_error (std::format (" Tried to unregister a hook with Lua function 'UnregisterHook' but the PreCallbackId supplied was too "
1389+ " large (>int32)\n >FunctionName: {}" ,
1390+ to_string (function_name_no_prefix)));
13871391 }
13881392
13891393 if (post_id > std::numeric_limits<int32_t >::max ())
13901394 {
1391- lua.throw_error (" Tried to unregister a hook with Lua function 'UnregisterHook' but the PostCallbackId supplied was too large (>int32)" );
1395+ lua.throw_error (std::format (" Tried to unregister a hook with Lua function 'UnregisterHook' but the PostCallbackId supplied was too "
1396+ " large (>int32)\n >FunctionName: {}" ,
1397+ to_string (function_name_no_prefix)));
13921398 }
13931399
13941400 // Hooks on native UFunctions will have both of these IDs.
@@ -1397,9 +1403,9 @@ No overload found for function 'UnregisterHook'.
13971403 if (native_hook_pre_id_it != LuaMod::m_generic_hook_id_to_native_hook_id.end () &&
13981404 native_hook_post_id_it != LuaMod::m_generic_hook_id_to_native_hook_id.end ())
13991405 {
1400- Output::send<LogLevel::Verbose>(STR (" Unregistering native hook with pre-id: {}\n " ), native_hook_pre_id_it->first );
1406+ Output::send<LogLevel::Verbose>(STR (" Unregistering native pre- hook ({}) for {}\n " ), native_hook_pre_id_it->first , function_name_no_prefix );
14011407 unreal_function->UnregisterHook (static_cast <int32_t >(native_hook_pre_id_it->second ));
1402- Output::send<LogLevel::Verbose>(STR (" Unregistering native hook with post-id: {}\n " ), native_hook_post_id_it->first );
1408+ Output::send<LogLevel::Verbose>(STR (" Unregistering native post- hook ({}) for {}\n " ), native_hook_post_id_it->first , function_name_no_prefix );
14031409 unreal_function->UnregisterHook (static_cast <int32_t >(native_hook_post_id_it->second ));
14041410
14051411 // LuaUnrealScriptFunctionData contains the hook's lua registry references, captured in RegisterHook in two different lua states.
@@ -1425,7 +1431,7 @@ No overload found for function 'UnregisterHook'.
14251431 if (auto callback_data_it = LuaMod::m_script_hook_callbacks.find (unreal_function->GetFullName ());
14261432 callback_data_it != LuaMod::m_script_hook_callbacks.end ())
14271433 {
1428- Output::send<LogLevel::Verbose>(STR (" Unregistering script hook with id: {}\n " ), post_id);
1434+ Output::send<LogLevel::Verbose>(STR (" Unregistering script hook with id: {}, FunctionName: {} \n " ), post_id, function_name_no_prefix );
14291435 auto & registry_indexes = callback_data_it->second .registry_indexes ;
14301436 std::erase_if (registry_indexes, [&](const auto & pair) -> bool {
14311437 return post_id == pair.second .identifier ;
@@ -3020,7 +3026,9 @@ No overload found for function 'RegisterHook'.
30203026 Unreal::UFunction* unreal_function = Unreal::UObjectGlobals::StaticFindObject<Unreal::UFunction*>(nullptr , nullptr , function_name_no_prefix);
30213027 if (!unreal_function)
30223028 {
3023- lua.throw_error (" Tried to register a hook with Lua function 'RegisterHook' but no UFunction with the specified name was found." );
3029+ lua.throw_error (std::format (
3030+ " Tried to register a hook with Lua function 'RegisterHook' but no UFunction with the specified name was found.\n Function Name: {}" ,
3031+ to_string (function_name_no_prefix)));
30243032 }
30253033
30263034 int32_t generic_pre_id{};
@@ -3062,6 +3070,7 @@ No overload found for function 'RegisterHook'.
30623070 else
30633071 {
30643072 std::string error_message{" Was unable to register a hook with Lua function 'RegisterHook', information:\n " };
3073+ error_message.append (fmt::format (" FunctionName: {}\n " , to_string (function_name_no_prefix)));
30653074 error_message.append (fmt::format (" UFunction::Func: {}\n " , std::bit_cast<void *>(func_ptr)));
30663075 error_message.append (fmt::format (" ProcessInternal: {}\n " , Unreal::UObject::ProcessInternalInternal.get_function_address ()));
30673076 error_message.append (
0 commit comments