1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
|
# testsuite_error_include section for BASIC256
# Modification History
# date programmer description
# 20140204 j.m.reneau split from testsuite
# 20160523 j.m.reneau 1.99.99.32 added logic to enforce that subroutines are called
# using the "CALL" statement - onerror uses lables and had to fix
currentsuite = "error"
goto skiperrortrap
# simple errortrap using subroutine and onerror
errortrap:
# do nothing but return so I can see error
return
skiperrortrap: ## jump over errortrap
onerror errortrap
print 8 / 0
call n("trap div zero", lasterror, 50)
throwerror 888
call n("trap throw 888", lasterror, 888)
offerror
# Error Trapping - Try Catch with gosub onerror for error in catch
goto trycatchtestjump
trycatchtest: # error trap for trycatch
a+= 2048
return
trycatchtestjump: ###
onerror trycatchtest
a = 0
try
a = a + 1
try
a = a + 16
throwerror 9999
a = a + 32
catch
a = a + 64
#error in catch actually back at previous level
throwerror 9999
a = a + 8
end try
a = a + 2
catch
a = a + 4
try
a = a + 128
throwerror 9999
a = a + 256
catch
a = a + 512
# error in catch/catch back in onerror
throwerror 9999
a = a + 1024
end try
a = a + 8
end try
offerror
call n("a=3805 try/catch",a,3805)
|