Explorar o código

Fixed out of order ebus connect/add_callback, added more context to error message (#13607)

* Fixed out of order ebus connect/add_callback, added more context to error message

Signed-off-by: AMZN-stankowi <[email protected]>

* Added nullcheck

Signed-off-by: AMZN-stankowi <[email protected]>

Signed-off-by: AMZN-stankowi <[email protected]>
AMZN-stankowi %!s(int64=2) %!d(string=hai) anos
pai
achega
42080d0fb4

+ 1 - 1
AutomatedTesting/TestAssets/test_chunks_builder.py

@@ -52,8 +52,8 @@ def on_update_manifest(args):
 def main():
     global mySceneJobHandler
     mySceneJobHandler = sceneApi.ScriptBuildingNotificationBusHandler()
-    mySceneJobHandler.add_callback('OnUpdateManifest', on_update_manifest)
     mySceneJobHandler.connect()
+    mySceneJobHandler.add_callback('OnUpdateManifest', on_update_manifest)
 
 if __name__ == "__main__":
     main()

+ 11 - 2
Gems/EditorPythonBindings/Code/Source/PythonProxyBus.cpp

@@ -189,13 +189,22 @@ namespace EditorPythonBindings
             {
                 if (!PyCallable_Check(callback.ptr()))
                 {
-                    AZ_Error("python", false, "The callback needs to be a callable python function.");
+                    [[maybe_unused]] AZStd::string ebusName(AZStd::string(m_ebus ? m_ebus->m_name : "invalid ebus"));
+                    AZ_Error("python", false, "The callback for event '%s' on bus '%.*s' needs to be a callable python function.",
+                        eventName.data(),
+                        AZ_STRING_ARG(ebusName));
                     return false;
                 }
 
                 if (!m_handler)
                 {
-                    AZ_Error("python", false, "No EBus connection detected; missing call or failed call to connect()?");
+                    [[maybe_unused]] AZStd::string ebusName(m_ebus ? m_ebus->m_name : "invalid ebus");
+                    AZ_Error(
+                        "python",
+                        false,
+                        "No EBus connection detected for event '%s'. Make sure to call to connect() on the %.*s bus, first.",
+                        eventName.data(),
+                        AZ_STRING_ARG(ebusName));
                     return false;
                 }