Write an exception to a log file

The following code writes the passed exception to a file named XSharpError.log in the application directory. If this file exists, the error is appended, otherwise the file is created first.

static class ErrorHandling
static method WriteErrorLog( oException as Exception ) as void
local cFileName as string
local oSB as StringBuilder

cFileName := Path.Combine( AppDomain.CurrentDomain:BaseDirectory, "XSharpError.log" )
oSB := StringBuilder{ String.Format( "Error occurred in {0} at {1}", Assembly.GetEntryAssembly():Location, DateTime.Now:ToString() ) }
oSB:AppendLine( "------------------------------------------------------------" )
oSB:AppendLine( oException:Message )
oSB:AppendLine( "Callstack:" )
oSB:AppendLine( oException:StackTrace )
oSB:AppendLine( "" )
File.AppendAllText( cFileName, oSB:ToString() )
	
return
end class