Code: Select all
; Thread ErrorHandler shows wrong ErrorLines.
Procedure T()
Repeat
ForEver
EndProcedure
Procedure ThreadWithError()
Protected i
Repeat
For i=1 To 1000000
Next
Until ElapsedMilliseconds()>800
zero=0
a=Random(42)
a=a/zero ; Error in Line 15
EndProcedure
#Errlog="/tmp/Err.dat" ; Please adapt.
OnErrorGoto(?ErrorHandler)
For i=1 To 4
CreateThread(@T(),0)
Next
CreateThread(@ThreadWithError,0)
Repeat
Until ElapsedMilliseconds()>1000
End
ErrorHandler:
OnErrorExit()
errfile=CreateFile(#PB_Any,#Errlog,#PB_File_NoBuffering)
WriteString(errfile,"ErrorLine: "+Str(ErrorLine()))
CloseFile(errfile)
End
CompilerIf #PB_Compiler_LineNumbering=0
CompilerError "Please switch Compiler Option OnError on."
CompilerEndIf
CompilerIf #PB_Compiler_Debugger=1
CompilerError "Please switch Compiler Option Start Debugger off."
CompilerEndIf
CompilerIf #PB_Compiler_Thread=0
CompilerError "Please switch Threadsave on."
CompilerEndIf
;ErrorLine: 3
;ErrorLine: 4