Page 1 of 1
XIDE Adventure
Posted: Sat Nov 25, 2023 2:22 pm
by OhioJoe
When I run a test application in XIDE it shows a black error screen that quickly disappears.
How can I capture that error?
Is it saved somewhere? Is there a setting I've missed?
Re: XIDE Adventure
Posted: Sat Nov 25, 2023 2:46 pm
by wriedmann
Hi Joe,
what is your Start() method? And are you talking about a VOGUI Classes application?
Anyway: try to put similar code in your Start() method:
Code: Select all
[STAThread];
function Start() as void
try
// Ein eigenes APP-Object setzen
oApp := EnhancedApp{}
__SetAppObject( oApp )
oApp:Start()
catch oEx as Exception
VOXSErrorHandler.ProcessException( oEx )
end try
return 0
And this is my Error handler:
Code: Select all
static class VOXSErrorHandler
static constructor()
return
static method UnhandledException( Sender as object, e as UnhandledExceptionEventArgs ) as void
VOXSErrorHandler.ProcessException( ( Exception ) e:ExceptionObject )
return
static method ProcessException( oException as Exception ) as void
local cMessage as string
cMessage := oException:Message
VOXSErrorHandler.WriteErrorLog( oException )
do while oException:InnerException != NULL_OBJECT
oException := oException:InnerException
VOXSErrorHandler.WriteErrorLog( oException )
cMessage += CRLF + oException:Message
enddo
VOXSErrorHandler.ErrBox( cMessage )
return
static method WriteErrorLog( oException as Exception ) as void
local cFileName as string
// local cErrorText 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
static method ErrBox( cText as string ) as void
local oParent as object
local oBox as TextBox
oParent := GetObjectByHandle( GetActiveWindow() )
if oParent == null_object
oParent := nil
endif
oBox := TextBox{ oParent, "Error", cText }
oBox:Type := BOXICONHAND
oBox:Beep := true
oBox:Show()
return
end class
After an exception you should find a XSharpError.log file in your application folder.
To have code lines in it you have to compile with Debug set to on.
Wolfgang
Re: XIDE Adventure
Posted: Sat Nov 25, 2023 4:37 pm
by FFF
Joe,
i'd suspect, your app is a console app and in Xide unter Tools/Preferences/General the setting "Add pause in console applications" is NOT set. Set it, and the screen will stay
Re: XIDE Adventure
Posted: Sat Nov 25, 2023 10:01 pm
by OhioJoe
Thank you both. It is a console app that I'm using to test some basic SQL routines.
Karl: That box is checked.
Wolfgang: I'll try to write an error handler based on the example you provided.
The adventure continues!
Re: XIDE Adventure
Posted: Sun Nov 26, 2023 7:14 am
by Chris
Hi Joe,
A cut down sample from Wolfgang's more sophisticated error handler, that will also do the job for simple test apps:
Code: Select all
FUNCTION Start() AS VOID
TRY
// do stuff
CATCH e AS Exception
? "Error happened:"
? e:ToString()
END TRY