FastForward.NET: Error Handling
Oh No, It’s Crashed!
It’s hard building real-world software. Not that writing software is hard, no it’s the “real-world” part that is hard! Why? Because the real world is messy!
I’m not talking about a little bit of mud or slime that can be easily wiped off, no, I’m talking about your kids haven’t cleaned their bedrooms in a year and they can’t that check they were supposed to bank three months ago messy. Times that by a hundred kids, in different countries, some of whom don’t even understand you!!
Not that I’m advocating sloppy coding, but sometimes, no matter how beautiful the code is, things just break. For no apparent reason (yes, I know it worked on your machine when you wrote it.) That’s why someone coined the term defensive programming. And like all developers, my code needs defensive code just as much.
Hence, in the next release I’ve added some error handling code.
You Mean It Isn’t Perfect?
Yes, FastForward.NET isn’t perfect
So I have added a generic handler for all unhandled exceptions (yes there are place were I expect problems and have error handling in place.) If one of these errors occur you’ll get a message like this:
This tells you there was an error, it logs the details and tells you where and then advises shutting down the application. I could have been mean and just killed the application, but I’ll give you the choice (it is highly recommended though!)
What’s in the Log?
The reason I generate the logs, is it is nice to get some data on what caused the crash. So, here is an example log:
1: <?xml version="1.0" encoding="utf-8"?>2: <errorLog>3: <environment time="2009-08-19T19:23:00.2808000+12:00"4: os="Microsoft Windows NT 6.0.6001 Service Pack 1"5: processors="2"6: clr="2.0.50727.3074" />7: <error type="System.Exception">8: <message>Hey, you've broken something!</message>9: <stack>10: at FastForward.Monitor.Plugins.BuildVisualisationDisplay.OnMouseDown(MouseEventArgs e) in C:\Open Source\FastForward.NET\trunk\project\FastForward.Monitor\Plugins\BuildVisualisationDisplay.cs:line 13611: at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)12: at System.Windows.Forms.Control.WndProc(Message& m)13: at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)14: at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)15: at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)16: at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)17: at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)18: at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)19: at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)20: at System.Windows.Forms.Application.Run(ApplicationContext context)21: at FastForward.Monitor.Program.Main() in C:\Open Source\FastForward.NET\trunk\project\FastForward.Monitor\Program.cs:line 4622: at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)23: at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)24: at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()25: at System.Threading.ThreadHelper.ThreadStart_Context(Object state)26: at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)27: at System.Threading.ThreadHelper.ThreadStart()28: </stack>29: </error>30: </errorLog>As you see, there’s nothing confidential
So it would be nice if you get one of these, if you could post it in the error report on Trac.
And of course, feel free to add any additional information you think would be helpful. I promise I will try to resolve any issues as fast as possible.