Skip to content
Snippets Groups Projects
Commit 13a7cabc authored by Heine, Eric R's avatar Heine, Eric R
Browse files

Wrapped the game event listeners in a try/catch block so that if some listener...

Wrapped the game event listeners in a try/catch block so that if some listener to a GameEvent throws an exception, any other GameEventListeners will still get their functions called.
parent fc2b5b9a
No related branches found
No related tags found
1 merge request!2Merge Request for Issue/4 Wrapped the game event listeners in a try/catch block so that if some listener...
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);
}
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment