Skip to content

Commit

Permalink
opt: log error by default
Browse files Browse the repository at this point in the history
  • Loading branch information
labbbirder committed Feb 18, 2024
1 parent 77d7975 commit d315186
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Editor/ShellRequest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Threading;
Expand Down Expand Up @@ -39,7 +40,6 @@ public void OnCompleted(Action continuation)
}
}


public IEnumerator ToCoroutine()
{
while (!IsCompleted)
Expand All @@ -49,7 +49,6 @@ public IEnumerator ToCoroutine()
}
}


public ShellResult Wait()
{
while (!IsCompleted)
Expand Down Expand Up @@ -88,6 +87,13 @@ public void Log(LogEventType type, string log)
foreach (var l in log.Split("\n"))
UnityEngine.Debug.LogError("<color=#808080>[ Shell Output ]</color>" + l);
}
else if (type == LogEventType.EndStream)
{
if (result.ExitCode != 0)
{
UnityEngine.Debug.LogError("<color=#808080>[ Shell Output ]</color>" + $"{result.Command} exit with code {result.ExitCode}");
}
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions Editor/ShellResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ internal ShellResult(string cmd)
internal void NotifyComplete(int exitCode)
{
ExitCode = exitCode;
if (!string.IsNullOrEmpty(Error))
{
UnityEngine.Debug.LogError($"cmd: {Command} error:\n{Error}");
}
}
internal void AppendLine(LogEventType type, string line)
{
Expand Down

0 comments on commit d315186

Please sign in to comment.