"You can't make a silk purse out of a sow's ear", and the onerror goto seems to be a bit of a sow's ear.
Maybe when local is introduced the thing will be cleaned up.
onerror goto only catches the very obvious anyway, which you should catch yourself while coding.
This test will probably give different results on different folks' boxes.
I tested here with 32/64 bits and -gen gas64
Code: Select all
'===============================================
#macro err1_
On Error Goto ehandler
#endmacro
#macro err2_
ehandler:
if Err() then
Dim As Integer Errnum = Err()
print "Error ";Errnum;" = ";
select case errnum
case 0 :print "No error"
case 1 :print "Illegal function call"
case 2 :print "File not found signal"
case 3 :print "File I/O error"
case 4 :print "Out of memory"
case 5 :print "Illegal resume"
case 6 :print "Out of bounds array access"
case 7 :print "Null Pointer Access"
case 8 :print "No privileges"
case 9 :print "interrupted signal"
case 10 :print "illegal instruction signal"
case 11 :print "floating point error signal"
case 12 :print "segmentation violation signal"
case 13 :print "Termination request signal"
case 14 :print "abnormal termination signal"
case 15 :print "quit request signal"
case 16 :print "return without gosub"
case 17 :print "end of file"
end select
print "Error function ";*erfn;" "+__function__
print "Error line ";Erl
sleep
end errnum
end if
#endmacro
#macro Echeck
err1_
err2_
#endmacro
'========================================================
#cmdline "-exx"
namespace mine
function dothis() as long
Echeck
dim as long ptr z
return *z
end function
end namespace
type udt extends object
declare sub dothis
end type
sub udt.dothis
Echeck
error 3
print "Hello"
end sub
dim as udt x
Sub test()
Echeck
dim as any ptr i
bload("xyz",i)
End Sub
function test2() as string
Echeck
open "nonesuch" for input as #1
close #1
return "abc"
end function
sub normal
print "Hello world!"
end sub
print test2()
test()
normal
print mine.dothis
x.dothis
Echeck
error 7
Here are my results as I comment the bad subs off one by one:
Code: Select all
Error 2 = File not found signal
Error function TEST2 TEST2
Error line 78
Error 12 = segmentation violation signal
Error function TEST TEST
Error line -1
Hello world!
Error 7 = Null Pointer Access
Error function DOTHIS MINE.DOTHIS
Error line 53
Error 3 = File I/O error
Error function DOTHIS UDT.DOTHIS
Error line 63
Error 7 = Null Pointer Access
Error function __FB_MAINPROC__
Error line 97