Revision history for ProPgErrorHandling


Revision [21209]

Last edited on 2016-03-13 12:43:54 by fxm [Formatting]

No Differences

Revision [20635]

Edited on 2016-02-10 16:12:45 by DkLwikki [Update link format]
Additions:
- By default the program does nothing with the errors - they are silently ignored and code continues. In this case code should process possible errors in the next line by using the ##[[KeyPgErr|Err]]## function.
- If compiled with //[[CompilerOpte|-e]]// or //[[CompilerOptex|-ex]]// options, ""FreeBASIC"" uses QB-like error handling.
Some IO functions such as ##[[KeyPgOpen|Open]]## and ##[[KeyPgPutfileio|Put #]]##... can be used in function form, returning an error number or zero if successful.
If the //[[CompilerOpte|-e]]// or //[[CompilerOptex|-ex]]// switch is used at compile time, the program is expected to have a QB-like error handler enabled. If no handler processes the error, the program stops with an error.
##[[KeyPgOnerror|On Error]]## sets an error handling routine which the program will jump to when an error is found. ##[[KeyPgOnerror|On Error]] [[KeyPgGoto|Goto]] 0## disables the error handling.
The error handler routine can be at the end of the program, as in QB. The ##[[KeyPgLocal|On Local Error]]## statement allows the setting of a local error handler routine at the end of the same ##[[KeyPgSub|Sub]]## or ##[[KeyPgFunction|Function]]## in which the error occurs.
" in function " & *Erfn & _
" on line " & Erl
If the //[[CompilerOpte|-e]]// switch is used (whatever the //[[CompilerOptlang|-lang]]// dialect), the error handler must terminate the program.
With //[[CompilerOptex|-ex]]// and //[[CompilerOptlang|-lang qb]]// dialect only, the error routine can end by using ##[[KeyPgResume|Resume]]## (retries the statement that caused the error) or ##[[KeyPgResumenext|Resume Next]]## (continues at the next instruction) .
See [[TblRuntimeErrors|Runtime Error Codes]] for a listing of runtime error numbers and their associated meaning.
No user error code range is defined. If ##[[KeyPgError|Error]]## is used to set an error code it is wise to use high values to avoid collisions with the list of built-in error codes. (This built-in list may be expanded later.)
- [[CatPgError|Error Handling Functions]]
- [[TblRuntimeErrors|Runtime Error Codes]]
Deletions:
- By default the program does nothing with the errors - they are silently ignored and code continues. In this case code should process possible errors in the next line by using the ##[[KeyPgErr Err]]## function.
- If compiled with //[[CompilerOpte -e]]// or //[[CompilerOptex -ex]]// options, ""FreeBASIC"" uses QB-like error handling.
Some IO functions such as ##[[KeyPgOpen Open]]## and ##[[KeyPgPutfileio Put #]]##... can be used in function form, returning an error number or zero if successful.
If the //[[CompilerOpte -e]]// or //[[CompilerOptex -ex]]// switch is used at compile time, the program is expected to have a QB-like error handler enabled. If no handler processes the error, the program stops with an error.
##[[KeyPgOnerror On Error]]## sets an error handling routine which the program will jump to when an error is found. ##[[KeyPgOnerror On Error]] [[KeyPgGoto Goto]] 0## disables the error handling.
The error handler routine can be at the end of the program, as in QB. The ##[[KeyPgLocal On Local Error]]## statement allows the setting of a local error handler routine at the end of the same ##[[KeyPgSub Sub]]## or ##[[KeyPgFunction Function]]## in which the error occurs.
" in function " & *Erfn & _
" on line " & Erl
If the //[[CompilerOpte -e]]// switch is used (whatever the //[[CompilerOptlang -lang]]// dialect), the error handler must terminate the program.
With //[[CompilerOptex -ex]]// and //[[CompilerOptlang -lang qb]]// dialect only, the error routine can end by using ##[[KeyPgResume Resume]]## (retries the statement that caused the error) or ##[[KeyPgResumenext Resume Next]]## (continues at the next instruction) .
See [[TblRuntimeErrors Runtime Error Codes]] for a listing of runtime error numbers and their associated meaning.
No user error code range is defined. If ##[[KeyPgError Error]]## is used to set an error code it is wise to use high values to avoid collisions with the list of built-in error codes. (This built-in list may be expanded later.)
- [[CatPgError Error Handling Functions]]
- [[TblRuntimeErrors Runtime Error Codes]]


Revision [16869]

Edited on 2013-06-22 18:16:02 by DkLwikki [Fix On Error example, var init is not supported in lang qb]
Additions:
Dim e as integer
Deletions:
Dim as integer e = Err


Revision [15161]

Edited on 2011-08-07 17:07:16 by FxMwikki [Fix On Error example, var init is not supported in lang qb]
Additions:
If the //[[CompilerOpte -e]]// switch is used (whatever the //[[CompilerOptlang -lang]]// dialect), the error handler must terminate the program.
With //[[CompilerOptex -ex]]// and //[[CompilerOptlang -lang qb]]// dialect only, the error routine can end by using ##[[KeyPgResume Resume]]## (retries the statement that caused the error) or ##[[KeyPgResumenext Resume Next]]## (continues at the next instruction) .
Deletions:
If the //[[CompilerOpte -e]]// switch is used the error handler must terminate the program.
With //[[CompilerOptex -ex]]// the error routine can end by using ##[[KeyPgResume Resume]]## (retries the statement that caused the error) or ##[[KeyPgResumenext Resume Next]]## (continues at the next instruction) .


Revision [14778]

Edited on 2010-08-20 08:41:35 by GaLeon [Changed QuickBasic to QuickBASIC.]
Additions:
{{fbdoc item="section" value="QuickBASIC-like error handling"}}
Deletions:
{{fbdoc item="section" value="QuickBasic-like error handling"}}


Revision [14131]

Edited on 2009-04-26 22:03:56 by CountingPine [Remove direct "Print Err"s; minor changes]
Additions:
""FreeBASIC"" can handle the errors in the following ways:
- By default the program does nothing with the errors - they are silently ignored and code continues. In this case code should process possible errors in the next line by using the ##[[KeyPgErr Err]]## function.
- If compiled with //[[CompilerOpte -e]]// or //[[CompilerOptex -ex]]// options, ""FreeBASIC"" uses QB-like error handling.
- **Future** OOP versions of ""FreeBASIC"" may have a java-like TRY..CATCH...FINALLY exception handler implemented.
**NOTE:** The following information is valid unless the error produces an OS General Protection Fault (for example if the program writes outside the process memory area). In these cases the OS will immediately stop the program and issue an error: nothing can avoid it from inside ""FreeBASIC"".
The default ""FreeBASIC"" behavior is to set the ERR variable and continue.
Dim as integer e
e = Err
Print e
(The example program supposes there is no ##xzxwz.zwz## file). The program does not stop; it sets the ERR variable and continues. The error can be processed in the next line.
Some IO functions such as ##[[KeyPgOpen Open]]## and ##[[KeyPgPutfileio Put #]]##... can be used in function form, returning an error number or zero if successful.
If the //[[CompilerOpte -e]]// or //[[CompilerOptex -ex]]// switch is used at compile time, the program is expected to have a QB-like error handler enabled. If no handler processes the error, the program stops with an error.
Notice: if QB-Like error handling is used, the programmer should be prepared to handle all error conditions.
Dim as integer e = Err
Print e
##[[KeyPgOnerror On Error]]## sets an error handling routine which the program will jump to when an error is found. ##[[KeyPgOnerror On Error]] [[KeyPgGoto Goto]] 0## disables the error handling.
The error handler routine can be at the end of the program, as in QB. The ##[[KeyPgLocal On Local Error]]## statement allows the setting of a local error handler routine at the end of the same ##[[KeyPgSub Sub]]## or ##[[KeyPgFunction Function]]## in which the error occurs.
Dim errmsg As String
errmsg = "Error " & Err & _
" in function " & *Erfn & _
" on line " & Erl
Print errmsg
If the //[[CompilerOpte -e]]// switch is used the error handler must terminate the program.
With //[[CompilerOptex -ex]]// the error routine can end by using ##[[KeyPgResume Resume]]## (retries the statement that caused the error) or ##[[KeyPgResumenext Resume Next]]## (continues at the next instruction) .
Deletions:
Freebasic can handle the errors in the following ways:
- By default the program does nothing with the errors - they are silently ignored and code continues. In this case code should process possible errors in the next line by using the ERR function.
- If compiled with //[[CompilerOpte -e]]// or //[[CompilerOptex -ex]]// options, FreeBASIC uses QB-like error handling.
- **Future** OOP versions of FreeBASIC may have a java-like TRY..CATCH...FINALLY exception handler implemented.
**NOTE:** The following information is valid unless the error produces an OS General Protection Fault (for example if the program writes outside the process memory area). In these cases the OS will immediately stop the program and issue an error: nothing can avoid it from inside FreeBASIC.
The default FreeBASIC behavior is to set the ERR variable and continue.
Print Err
(The example program supposes there is no ##xzxwz.zwz## file). The program does not stop, it sets the ERR variable and continues. The error can be processed in the next line.
Some IO functions such as OPEN and PUT... can be used in FUNCTION form, returning an error number or zero if successful.
If the -e or -ex switch is used at compile time, the program is expected to have a QB-like error handler enabled. If no handler processes the error, the program stops with an error.
Notice: if QB-Like error handling is used, the programmer should be prepared to handle ALL error conditions. For example GETMOUSE issues an error if the cursor goes off the window.
Print Err
ON ERROR sets an error handling routine which the program will jump to when an error is found. ON ERROR GOTO 0 disables the error handling.
The error handler routine can be at the end of the program, as in QB. The ON LOCAL ERROR allows the setting of a local error handler routine at the end of the same SUB or FUNCTION in which the error occurs.
Print ("Error " & Err & " in function " & *Erfn & " on line " & Erl)
If the -e switch is used the error handler must terminate the program.
With -ex the error routine can end by using RESUME (retries the statement that caused the error) or RESUME NEXT (continues at the next instruction)


Revision [13545]

Edited on 2008-07-21 15:42:53 by JeffMarshall [added #lang or $lang to example]
Additions:
'$lang: "qb"


Revision [13237]

The oldest known version of this page was created on 2008-04-26 09:10:37 by JeffMarshall [added #lang or $lang to example]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode