1 /* ErrorService.cs $
\r
2 This file is part of the HandBrake source code.
\r
3 Homepage: <http://handbrake.fr>.
\r
4 It may be used under the terms of the GNU General Public License. */
\r
6 namespace HandBrake.Framework.Services
\r
10 using System.Threading;
\r
12 using HandBrake.Framework.Services.Interfaces;
\r
13 using HandBrake.Framework.Views;
\r
16 /// The Error Service
\r
18 public class ErrorService : IErrorService
\r
21 /// Show an Error Window
\r
23 /// <param name="shortError">
\r
24 /// The short error message for the user to read
\r
26 /// <param name="longError">
\r
27 /// Exception string or advanced details
\r
29 public void ShowError(string shortError, string longError)
\r
33 Thread newThread = new Thread(new ParameterizedThreadStart(WriteExceptionToFile));
\r
34 newThread.Start(shortError + Environment.NewLine + longError);
\r
41 ExceptionWindow window = new ExceptionWindow();
\r
42 window.Setup(shortError, longError);
\r
47 /// Show a Notice or Warning Message.
\r
49 /// <param name="notice">
\r
50 /// The text to display to the user
\r
52 /// <param name="isWarning">
\r
53 /// Is a warning window, show the warning icon instead of the notice
\r
55 public void ShowNotice(string notice, bool isWarning)
\r
57 throw new NotImplementedException();
\r
61 /// Write Exceptions out to log files
\r
63 /// <param name="state">
\r
66 public void WriteExceptionToFile(object state)
\r
70 string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";
\r
71 string file = Path.Combine(logDir, string.Format("Exception_{0}.txt", DateTime.Now.Ticks));
\r
73 if (!File.Exists(file))
\r
75 using (StreamWriter streamWriter = new StreamWriter(file))
\r
77 streamWriter.WriteLine(state.ToString());
\r
78 streamWriter.Close();
\r
79 streamWriter.Dispose();
\r
85 return; // Game over. Stop digging.
\r