Skip to content
Snippets Groups Projects

Merge Request for Issue/4 Wrapped the game event listeners in a try/catch block so that if some listener...

Merged Heine, Eric R requested to merge issue/4-game-event-exception-catching into master
1 file
+ 16
3
Compare changes
  • Side-by-side
  • Inline
using UnityEngine;
using System;
using UnityEngine;
using UnityEngine.Events;
namespace Shared.ScriptableVariables {
@@ -23,7 +24,13 @@ namespace Shared.ScriptableVariables {
//---------------------------------------------------------------------------
public virtual void OnEventRaised() {
if (response != null) {
response.Invoke();
try {
response.Invoke();
}
catch (Exception exception) {
Debug.LogError($"{gameObject.name} is throwing the following exception:");
Debug.LogException(exception);
}
}
}
}
@@ -50,7 +57,13 @@ namespace Shared.ScriptableVariables {
public virtual void OnEventRaised(T value) {
var unityEvent = GetUnityEvent();
if (unityEvent != null) {
unityEvent.Invoke(value);
try {
unityEvent.Invoke(value);
}
catch (Exception exception) {
Debug.LogError($"{gameObject.name} is throwing the following exception:");
Debug.LogException(exception);
}
}
}
}
Loading