Skip to content

Commit bf53223

Browse files
committed
WIP custom error handler
1 parent e964f7e commit bf53223

File tree

3 files changed

+58
-0
lines changed

3 files changed

+58
-0
lines changed

.claude/settings.local.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"permissions": {
3+
"allow": [
4+
"Bash(ls:*)",
5+
"Bash(find:*)",
6+
"Bash(grep:*)"
7+
],
8+
"deny": []
9+
}
10+
}

Runtime/Scripts/ErrorHandler.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using System;
2+
using System.Collections;
3+
using UnityEngine;
4+
5+
namespace BetaHub
6+
{
7+
/// <summary>
8+
/// Provides consistent error handling for operations throughout the BetaHub plugin.
9+
/// </summary>
10+
public static class ErrorHandler
11+
{
12+
/// <summary>
13+
/// Executes a synchronous operation with return value and consistent error handling.
14+
/// </summary>
15+
/// <typeparam name="T">The return type</typeparam>
16+
/// <param name="operation">The operation to execute</param>
17+
/// <param name="onSuccess">Optional callback for successful completion with result</param>
18+
/// <param name="onError">Optional callback for error handling</param>
19+
public static void Execute<T>(
20+
Func<T> operation,
21+
Action<T> onSuccess = null,
22+
Action<string> onError = null)
23+
{
24+
try
25+
{
26+
T result = operation();
27+
onSuccess?.Invoke(result);
28+
}
29+
catch (Exception ex)
30+
{
31+
string errorMessage = ex.Message;
32+
Debug.LogError($"ErrorHandler: {errorMessage}");
33+
onError?.Invoke(errorMessage);
34+
}
35+
}
36+
}
37+
}

Runtime/Scripts/ErrorHandler.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)