48 lines
764 B
Text
48 lines
764 B
Text
' FB 1.05.0 Win64
|
|
|
|
Enum ErrorTypes
|
|
U0 = 1000
|
|
U1
|
|
End Enum
|
|
|
|
Function errorName(ex As ErrorTypes) As String
|
|
Select Case As Const ex
|
|
Case U0
|
|
Return "U0"
|
|
Case U1
|
|
Return "U1"
|
|
End Select
|
|
End Function
|
|
|
|
Sub catchError(ex As ErrorTypes)
|
|
Dim e As Integer = Err '' cache the error number
|
|
If e = ex Then
|
|
Print "Error "; errorName(ex); ", number"; ex; " caught"
|
|
End If
|
|
End Sub
|
|
|
|
Sub baz()
|
|
Static As Integer timesCalled = 0 '' persisted between procedure calls
|
|
timesCalled += 1
|
|
If timesCalled = 1 Then
|
|
err = U0
|
|
Else
|
|
err = U1
|
|
End if
|
|
End Sub
|
|
|
|
Sub bar()
|
|
baz
|
|
End Sub
|
|
|
|
Sub foo()
|
|
bar
|
|
catchError(U0) '' not interested in U1, assumed non-fatal
|
|
bar
|
|
catchError(U0)
|
|
End Sub
|
|
|
|
Foo
|
|
Print
|
|
Print "Press any key to quit"
|
|
Sleep
|