Skip to content

Commit

Permalink
Capture errors from asserts in pipeline output.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomspilman committed Oct 5, 2024
1 parent 8847878 commit ee7e087
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions Tools/MonoGame.Content.Builder/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,39 @@ namespace MonoGame.Content.Builder
{
class Program
{
public class AssertListener : TraceListener
{
public override void Write(string message)
{
Console.Write(message);
}

public override void WriteLine(string message)
{
Console.WriteLine(message);
}

public override void Fail(string message, string detailMessage)
{
Console.WriteLine(message);

if (!string.IsNullOrEmpty(detailMessage))
Console.WriteLine(detailMessage);
}
}

static int Main(string[] args)
{
// We force all stderr to redirect to stdout
// to avoid any out of order console output.
Console.SetError(Console.Out);

// Hook in our own trace listener so that errors
// from asserts appear in the output logging instead
// of having silent failures.
Trace.Listeners.Clear();
Trace.Listeners.Add(new AssertListener());

if (!Environment.Is64BitProcess && Environment.OSVersion.Platform != PlatformID.Unix)
{
Console.Error.WriteLine("The MonoGame content tools only work on a 64bit OS.");
Expand Down

0 comments on commit ee7e087

Please sign in to comment.