[quote=352139:@Jon Ogden]Greg,
I never had a problem with this until now. It’s always worked fine. I know one of the crashes I had was definitely due to a stack overflow like you stated. And that was an error I did fix. But others seem to be related to IteratorException errors in the framework (see:
Here’s my code (and yes the “Return True” on the OutOfMemoryException is probably not the best but the issue that would rarely raise that has gone away with 64 bit now).
So the code basically alerts the user of the problem, creates a log file with the stack info and then uploads it to my FTP server.
[code]
Dim type as String
If error IsA OutOfMemoryException Then
Return True
End If
Dim mystack() as string = error.Stack
If error <> Nil Then
type = Introspection.GetType(error).Name
ErrorMessage ="An unhandled error occured. A crash log file with today’s date has been created in your application folder. Please send this to support@justaddsoftware.net "+EndofLine+EndofLine+ _
"Information about the error: “+type + EndOfLine + EndOfLine +Join(error.Stack, EndOfLine).Left(200)+EndofLine+EndofLine+“Please cancel out of what you were doing and try again.”+EndOfLine+EndOfLine+ _
app.LongVersion+” "+Str(MajorVersion) + “.” + Str(MinorVersion) + “.” _
- Str(BugVersion) + “.” + Str(NonReleaseVersion)
ErrorTimer.Mode = Timer.ModeSingle
ErrorTimer.Reset
End If
Dim d as new Date
Dim f as folderitem = GetFolderItem(“MediaSwitcherLog_”+str(d.month)+"-"+str(d.day)+"-"+str(d.year)+"_"+str(d.Hour)+"-"+str(d.Minute)+"-"+str(d.Second)+".txt")
If f.Exists Then
f = GetFolderItem(“MediaSwitcherLog_”+str(d.month)+"-"+str(d.day)+"-"+str(d.year)+"_"+str(d.Hour)+"-"+str(d.Minute)+"-"+str(d.Second)+"-a.txt")
End If
#pragma BreakOnExceptions Off
try
Dim bs as binarystream = binarystream.create(f)
bs.Write type+EndOfLine
bs.write Join(error.Stack, EndOfLine)
bs.Write app.LongVersion+" "+Str(MajorVersion) + “.” + Str(MinorVersion) + “.”+ Str(BugVersion) + “.” + Str(NonReleaseVersion)
bs = nil
catch
end try
Dim bs as BinaryStream = BinaryStream.Open(f)
Dim uftp as New FTPUploadClass
uftp.UploadFTP(“MS_ExceptionError_From_”+App.RegName+"-"+App.RegEmail+"_"+Xojo.Core.Date.Now.ToText+".txt", bs)
Return True
[/code][/quote]
You probably miss some code that could help.
If f = nil then some error can occour.
the first binarystream.Create(f) and the first binarystream.Open(f) can be using a Nil folderitem for whatever reason.
If f.Exists and f <> Nil Then
and:
If you catch an error on the binary stream you are still opening the bottom binary stream. It’s better to just use try - catch - end try on both binary stream instances.
try
Dim bs as BinaryStream = BinaryStream.Open(f)
Dim uftp as New FTPUploadClass
uftp.UploadFTP("MS_ExceptionError_From_"+App.RegName+"-"+App.RegEmail+"_"+Xojo.Core.Date.Now.ToText+".txt", bs)
catch
'do something
end try