Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono-tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel de Icaza <miguel@gnome.org>2009-09-08 06:01:54 +0400
committerMiguel de Icaza <miguel@gnome.org>2009-09-08 06:01:54 +0400
commit894df04823d9daa845d542aaaa5216a3b949fc21 (patch)
treeb2bfbaabae70599f00a572188a93e0f64bf8b965
parent60b38e093a315eee2b03c260ef1dffe01e78af71 (diff)
Allow exceptions to go to the console
svn path=/trunk/mono-tools/; revision=141480
-rw-r--r--gsharp/Main.cs22
1 files changed, 12 insertions, 10 deletions
diff --git a/gsharp/Main.cs b/gsharp/Main.cs
index 2dc86749..06f1dd2f 100644
--- a/gsharp/Main.cs
+++ b/gsharp/Main.cs
@@ -10,6 +10,7 @@ using System.Diagnostics;
using System.Reflection;
using Mono.Options;
using System.Collections.Generic;
+using System.IO;
namespace Mono.CSharp.Gui
{
@@ -25,6 +26,14 @@ namespace Mono.CSharp.Gui
p.WriteOptionDescriptions (Console.Out);
}
+
+ static void ResetOutput ()
+ {
+ var stdout = new StreamWriter (Console.OpenStandardOutput ()) { AutoFlush = true };
+ var stderr = new StreamWriter (Console.OpenStandardError ()) { AutoFlush = true };
+ Console.SetOut (stdout);
+ Console.SetError (stderr);
+ }
public static void Main (string[] args)
{
@@ -122,22 +131,15 @@ namespace Mono.CSharp.Gui
m.ShowAll ();
if (!HostHasGtkRunning){
- System.IO.TextWriter cout = Console.Out;
- System.IO.TextWriter cerr = Console.Error;
-
try {
GLib.ExceptionManager.UnhandledException += delegate (GLib.UnhandledExceptionArgs a) {
- Console.SetOut (cout);
- Console.SetError (cerr);
-
+ ResetOutput ();
Console.WriteLine ("Application terminating: " + a.ExceptionObject);
};
Application.Run ();
- } catch (Exception) {
- Console.SetOut (cout);
- Console.SetError (cerr);
-
+ } catch (Exception e) {
+ ResetOutput ();
throw;
}
}