Skip to content

Commit d7387cc

Browse files
authored
Merge pull request #30 from CandyCoded/hotfix/error-handling
[hotfix] Error handling
2 parents 48f8f8c + 0e99b8c commit d7387cc

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

Assets/Plugins/CandyCoded.GitStatus/Scripts/CustomEditor/Git.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// Copyright (c) Scott Doxey. All Rights Reserved. Licensed under the MIT License. See LICENSE in the project root for license information.
22

33
#if UNITY_EDITOR
4+
using System;
45
using System.Collections.Generic;
56
using System.Diagnostics;
67
using System.Threading.Tasks;
7-
using Debug = UnityEngine.Debug;
88

99
namespace CandyCoded.GitStatus
1010
{
@@ -93,7 +93,7 @@ public static async Task DiscardChanges(string path)
9393
if (process?.StandardError.ReadLine() is string line && line.StartsWith("error: pathspec"))
9494
{
9595

96-
Debug.LogError("File not tracked by git.");
96+
throw new Exception("File not tracked by git.");
9797

9898
}
9999

Assets/Plugins/CandyCoded.GitStatus/Scripts/CustomEditor/GitMenuItems.cs

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,18 @@ private static string GetSelectedPath()
2525
private static async void DiscardChanges()
2626
{
2727

28-
await Git.DiscardChanges(GetSelectedPath());
28+
try
29+
{
30+
31+
await Git.DiscardChanges(GetSelectedPath());
32+
33+
}
34+
catch (Exception error)
35+
{
36+
37+
EditorUtility.DisplayDialog("Error", error.Message, "Ok");
38+
39+
}
2940

3041
}
3142

@@ -49,8 +60,18 @@ private static async void DiscardAllChanges()
4960
"Yes",
5061
"Cancel"))
5162
{
63+
try
64+
{
5265

53-
await Git.DiscardChanges(GetSelectedPath());
66+
await Git.DiscardChanges(GetSelectedPath());
67+
68+
}
69+
catch (Exception error)
70+
{
71+
72+
EditorUtility.DisplayDialog("Error", error.Message, "Ok");
73+
74+
}
5475

5576
}
5677

0 commit comments

Comments
 (0)