Skip to content

Commit

Permalink
feat: add on-exception callback
Browse files Browse the repository at this point in the history
  • Loading branch information
bdunderscore committed Sep 20, 2023
1 parent 339b355 commit 77a6fe8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Editor/API/BuildContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,10 @@ internal void RunPass(ConcretePass pass)
{
pass.Execute(this);
}
catch (Exception e)
{
pass.Plugin.OnUnhandledException(e);
}
finally
{
Profiler.EndSample();
Expand Down
20 changes: 20 additions & 0 deletions Editor/API/Fluent/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Threading;
using nadena.dev.ndmf.fluent;
using UnityEngine;

#endregion

Expand All @@ -14,6 +15,8 @@ internal interface IPlugin
string DisplayName { get; }

void Configure(PluginInfo info);

void OnUnhandledException(Exception e);
}

public abstract class Plugin<T> : IPlugin where T : Plugin<T>, new()
Expand Down Expand Up @@ -54,5 +57,22 @@ protected Sequence InPhase(BuildPhase phase)

return _info.NewSequence(phase);
}

/// <summary>
/// Invoked when a pass in this plugin throws an exception. This exception can be passed to a plugin's own error
/// handling UI.
///
/// This API will likely be deprecated once a native error-reporting system is available.
/// </summary>
/// <param name="e"></param>
protected virtual void OnUnhandledException(Exception e)
{
Debug.LogException(e);
}

void IPlugin.OnUnhandledException(Exception e)
{
OnUnhandledException(e);
}
}
}

0 comments on commit 77a6fe8

Please sign in to comment.