Skip to content
This repository has been archived by the owner on Apr 16, 2020. It is now read-only.

Commit

Permalink
Write error messages to STDERR (#376)
Browse files Browse the repository at this point in the history
* Write error message to STDERR

* More error messages that belong on STDERR
  • Loading branch information
atifaziz authored and ctaggart committed May 23, 2019
1 parent c9c39ca commit be8dcda
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions dotnet-sourcelink/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static int Main(string[] args)
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.Error.WriteLine(ex.Message);
return -1;
}
}
Expand All @@ -67,20 +67,20 @@ public static void PrintJson(CommandLineApplication command)
}
if (!File.Exists(path))
{
Console.WriteLine("file does not exist: " + path);
Console.Error.WriteLine("file does not exist: " + path);
return 3;
}
using (var drp = DebugReaderProvider.Create(path))
{
if(drp == null)
{
Console.WriteLine("unable to read debug info: " + path);
Console.Error.WriteLine("unable to read debug info: " + path);
return 5;
}
var bytes = GetSourceLinkBytes(drp);
if (bytes == null || bytes.Length == 0)
{
Console.WriteLine("Source Link JSON not found in file: " + path);
Console.Error.WriteLine("Source Link JSON not found in file: " + path);
return 4;
}
Console.WriteLine(Encoding.UTF8.GetString(bytes));
Expand All @@ -106,15 +106,15 @@ public static void PrintDocuments(CommandLineApplication command)
}
if (!File.Exists(path))
{
Console.WriteLine("file does not exist: " + path);
Console.Error.WriteLine("file does not exist: " + path);
return 3;
}

using (var drp = DebugReaderProvider.Create(path))
{
if (drp == null)
{
Console.WriteLine("unable to read debug info: " + path);
Console.Error.WriteLine("unable to read debug info: " + path);
return 4;
}
foreach (var doc in GetDocuments(drp))
Expand Down Expand Up @@ -143,15 +143,15 @@ public static void PrintUrls(CommandLineApplication command)
}
if (!File.Exists(path))
{
Console.WriteLine("file does not exist: " + path);
Console.Error.WriteLine("file does not exist: " + path);
return 3;
}

using (var drp = DebugReaderProvider.Create(path))
{
if (drp == null)
{
Console.WriteLine("unable to read debug info: " + path);
Console.Error.WriteLine("unable to read debug info: " + path);
return 5;
}
var missingDocs = new List<Document>();
Expand All @@ -174,10 +174,10 @@ public static void PrintUrls(CommandLineApplication command)
}
if (missingDocs.Count > 0)
{
Console.WriteLine("" + missingDocs.Count + " Documents without URLs:");
Console.Error.WriteLine("" + missingDocs.Count + " Documents without URLs:");
foreach (var doc in missingDocs)
{
Console.WriteLine("{0} {1} {2} {3}", doc.Hash.ToHex(), HashAlgorithmGuids.GetName(doc.HashAlgorithm), LanguageGuids.GetName(doc.Language), doc.Name);
Console.Error.WriteLine("{0} {1} {2} {3}", doc.Hash.ToHex(), HashAlgorithmGuids.GetName(doc.HashAlgorithm), LanguageGuids.GetName(doc.Language), doc.Name);
}
return 4;
}
Expand All @@ -193,7 +193,7 @@ public static int TestFile(string path, IAuthenticationHeaderValueProvider authe
{
if (drp == null)
{
Console.WriteLine("unable to read debug info: " + path);
Console.Error.WriteLine("unable to read debug info: " + path);
return 5;
}
return TestFile(drp, authenticationHeaderValueProvider);
Expand Down Expand Up @@ -308,7 +308,7 @@ public static int TestNupkg(string path, List<string> files, IAuthenticationHead
{
if (drp == null)
{
Console.WriteLine("unable to read debug info: " + path);
Console.Error.WriteLine("unable to read debug info: " + path);
return 5;
}
if (TestFile(drp, authenticationHeaderValueProvider) != 0)
Expand Down Expand Up @@ -357,7 +357,7 @@ public static void Test(CommandLineApplication command)
}
if (!File.Exists(path))
{
Console.WriteLine("file does not exist: " + path);
Console.Error.WriteLine("file does not exist: " + path);
return 3;
}

Expand Down

0 comments on commit be8dcda

Please sign in to comment.