Skip to main content

  | मौसम…

411 समाचार
Public archive edition · Attributed source reporting with original dates · AI drafts are excluded

411 REFERENCE · Wikibooks

BlitzMax/Language/Exceptions

Reference material by Wikibooks contributors. This retains its source identity and is not 411 news reporting.

BlitzMax provides a mechanism for handling runtime errors known as exception handling An exception is actually just an object. You can throw and catch exceptions using the Throw command and a Try / Catch block. Here is a simple example: Function ExTest() Throw "Bingo!" End Function Try ExTest() Catch ex:Object Print ex.ToString() End Try Throwing an exception causes the program to jump to the most recent Catch block. You can provide multiple catch blocks for catching exceptions of different types. If there is no appropriate Catch block for the exception, then the program jumps to the next most recent Catch block. If no catch block can be found to deal with the exception, the program will end. BlitzMax has several built-in exception types, all of which extend type TBlitzException. These are: Exception Cause TNullMethodException Thrown when a program attempts to call an abstract method. TNullFunctionException Thrown when a program attempts to call a null function. TNullObjectException Thrown when a program attempts to access a null object (only thrown in debug mode). TArrayBoundsException Thrown when a program attempts to access an array element outside of an array's bounds (only thrown in debug mode). TRuntimeException Thrown by the RuntimeError or Assert commands.