CATCH
CATCH [var | expr]
The CATCH statement is used to catch a run-time error. This is typically used with errors raised when calling a file system command that cannot be completed, for example attempting to open a non-existent file.
The CATCH statement has two modes. You can supply a variable argument to store the error string. Alternatively you can supply an expression. When the raised error matches the (String) expression, the error will be caught. When using the expression mode, you can supply a succession of CATCH statements to handle various error messages separately.
For more information see TRY.
Example
try
' DON'T use existing file for demo.
open "try demo.tmp" for input as #1
catch err
print err
' Some error handling could be implemented here
' i.e: if(err = "...") then ...
end try
print "This point is reach, even if opening the file was not possible"
Code samples using CATCH
Language
AND
AS
BAND
BG
BOR
BYREF
CALL
CASE
CATCH
CONST
DECLARE
DEF
DO
ELIF
ELSE
ELSEIF
END
END TRY
ENDIF
EQV
EXIT
FALSE
FI
FOR
FUNC
GOSUB
GOTO
IF
IFF
IMP
IN
LABEL
LET
LIKE
LOCAL
LSHIFT
MDL
MOD
NAND
NEXT
NOR
NOT
ON
OR
REM
REPEAT
RETURN
RSHIFT
SELECT
STEP
STOP
SUB
THEN
THROW
TO
TRUE
TRY
UNTIL
USE
USG
USING
WEND
WHILE
XNOR
XOR
If there is insufficient information on this page and you wish learn more about CATCH,
please send an email to smallbasic@gmail.com. You can help to improve information about
CATCH by submitting a pull request,
click View Source for details. Note, an offline language reference text file is also available - see the Download section.