using UnityEngine;
namespace JustTrack
{
///
/// Handles Unity application exceptions for the justtrack SDK.
///
public class ExceptionHandler
{
///
/// Delegate for handling exception events.
///
/// The exception message.
/// The exception stack trace.
public delegate void OnReceiveExceptionHandler(string message, string stackTrace);
///
/// Event raised when an exception is received.
///
public event OnReceiveExceptionHandler? OnReceiveException;
///
/// Initializes a new instance of the class.
///
public ExceptionHandler()
{
Application.logMessageReceived += HandleLog;
}
///
/// Finalizes an instance of the class.
///
~ExceptionHandler()
{
Application.logMessageReceived -= HandleLog;
}
private void HandleLog(string logString, string stackTrace, LogType type)
{
if (type == LogType.Exception)
{
OnReceiveException?.Invoke(logString, stackTrace);
}
}
}
}