Skip to content

Commit e559c46

Browse files
committed
Add diagnostics logs and better error handling
1 parent e964f7e commit e559c46

File tree

5 files changed

+329
-135
lines changed

5 files changed

+329
-135
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Thumbs.db
3939
# =============== #
4040
.vs/
4141
.vscode/
42+
.claude/
4243

4344
# =============== #
4445
# Rider #
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
using System;
2+
using UnityEngine;
3+
4+
namespace BetaHub
5+
{
6+
/// <summary>
7+
/// Interface for contextual diagnostics providing error handling and logging capabilities.
8+
/// </summary>
9+
public interface IContextualDiagnostics
10+
{
11+
/// <summary>
12+
/// Logs an informational message for an operation.
13+
/// </summary>
14+
void LogInfo(string operation, string message);
15+
16+
/// <summary>
17+
/// Logs a successful operation completion.
18+
/// </summary>
19+
void LogSuccess(string operation, string message);
20+
21+
/// <summary>
22+
/// Logs progress information for a long-running operation.
23+
/// </summary>
24+
void LogProgress(string operation, string message);
25+
26+
/// <summary>
27+
/// Logs an error with a custom message and exception details.
28+
/// </summary>
29+
void LogError(string operation, string message, Exception ex = null);
30+
}
31+
32+
/// <summary>
33+
/// Main entry point for BetaHub diagnostics.
34+
/// </summary>
35+
public static class BetaHubDiagnostics
36+
{
37+
/// <summary>
38+
/// Creates a contextual diagnostics service for a specific component or operation context.
39+
/// </summary>
40+
public static IContextualDiagnostics ForContext(string contextName)
41+
{
42+
return new ContextualDiagnostics(contextName);
43+
}
44+
}
45+
46+
/// <summary>
47+
/// Implementation of contextual diagnostics that provides consistent logging.
48+
/// </summary>
49+
internal class ContextualDiagnostics : IContextualDiagnostics
50+
{
51+
private readonly string _contextName;
52+
53+
public ContextualDiagnostics(string contextName)
54+
{
55+
_contextName = contextName ?? throw new ArgumentNullException(nameof(contextName));
56+
}
57+
58+
public void LogInfo(string operation, string message)
59+
{
60+
Debug.Log($"[INFO] {_contextName}.{operation}: {message}");
61+
}
62+
63+
public void LogSuccess(string operation, string message)
64+
{
65+
Debug.Log($"[SUCCESS] {_contextName}.{operation}: {message}");
66+
}
67+
68+
public void LogProgress(string operation, string message)
69+
{
70+
Debug.Log($"[PROGRESS] {_contextName}.{operation}: {message}");
71+
}
72+
73+
public void LogError(string operation, string message, Exception ex = null)
74+
{
75+
string errorMessage = ex != null
76+
? $"[ERROR] {_contextName}.{operation}: {message} - {ex.Message}\n{ex.StackTrace}"
77+
: $"[ERROR] {_contextName}.{operation}: {message}";
78+
Debug.LogError(errorMessage);
79+
}
80+
}
81+
}

Runtime/Scripts/BetaHubDiagnostics.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.

Runtime/Scripts/BugReportUI.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -546,10 +546,6 @@ private IEnumerator SubmitBugReportCoroutine()
546546
BugReportPanel.SetActive(false);
547547
},
548548
MediaUploadType,
549-
(error) =>
550-
{
551-
onIssueError(new ErrorMessage { error = error });
552-
},
553549
customFieldsData.Count > 0 ? customFieldsData : null
554550
),
555551
(ex) => // done

0 commit comments

Comments
 (0)