Wiki source for KeyPgError

Show raw source

{{fbdoc item="title" value="ERROR"}}----
Error handling statement to force an error to be generated

{{fbdoc item="syntax"}}##
[[KeyPgDeclare|declare]] [[KeyPgSub|sub]] **Error** ( //errno// [[KeyPgAs|as]] [[KeyPgInteger|integer]] )
{{fbdoc item="usage"}}##
**Error** //number//
{{fbdoc item="param"}}
The error number to generate

{{fbdoc item="desc"}}
**Error** invokes the error handler specified with [[KeyPgOnerror|On Error]] or, in case there was none set, aborts the program, printing an error message similar to those generated by the compiler's -exx run-time error checking. It's possible to use the [[TblRuntimeErrors|built-in run-time error numbers]] and/or other custom error numbers for //number//. This can be used to simulate custom error numbers.

{{fbdoc item="ex"}}
To send an error alert of error 150 (just some arbitrary error code) one would do the following:
{{fbdoc item="filename" value="examples/manual/error/error.bas"}}%%(freebasic)
error 150

{{fbdoc item="diff"}}
- Error numbers are not the same as in QB.

{{fbdoc item="see"}}
- ##[[KeyPgErr|Err]]##
- {{fbdoc item="keyword" value="ProPgErrorHandling|Error Handling"}}
- [[TblRuntimeErrors|Runtime Error Codes]]

{{fbdoc item="back" value="CatPgError|Error Handling Functions"}}
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki phatcode