The THROW statement raises a runtime exception.
THROW [expression]
expression | An optional expression to throw. |
THROW throws a runtime exception, causing execution to branch to the nearest CATCH or FINALLY block in a TRY construct. If execution is not within a TRY construct the application will terminate.
The specified expression is passed to the CATCH statement, if any, and must be of type System.Exception or a class derived from it . See TRY-CATCH-FINALLY fro more information.
Using THROW within a CATCH block without any arguments re-throws the exception, passing it unchanged to the next highest TRY-CATCH block.
USING System.IO
FUNCTION ReadFile( filename AS STRING ) AS STRING
LOCAL s AS STRING
TRY
s := File.ReadAllText( filename )
CATCH e AS DirectoryNotFoundException
? "Directory not found", e
CATCH e AS IOException
? "IO exception occurred", e
CATCH e AS UnauthorizedAccessException
? "Access denied", e
CATCH
? "Some other exception"
// Escalate error to next TRY-CATCH
THROW
FINALLY
? "All done!"
END TRY
RETURN s