ERROR Codes: Difference between revisions
No edit summary |
No edit summary |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
This page lists all the error codes defined in QB64 that can occur in a program when running. Unless overridden with an [[ON ERROR]] handler, these result in a dialog box appearing. Due to legacy holdovers from previous BASIC dialects, not all of these errors may actually occur in a program (unless manually triggered with [[ERROR]]). | This page lists all the error codes defined in QB64 that can occur in a program when running. Unless overridden with an [[ON ERROR]] handler, these result in a dialog box appearing. Due to legacy holdovers from previous BASIC dialects, not all of these errors may actually occur in a program (unless manually triggered with [[ERROR]]). | ||
Line 5: | Line 4: | ||
If you encounter an error while editing in the QB64 IDE or when compiling (especially a "C++ Compilation Failed" message), or believe your program is correct, please report the error at https://github.com/QB64-Phoenix-Edition/QB64pe/issues. | If you encounter an error while editing in the QB64 IDE or when compiling (especially a "C++ Compilation Failed" message), or believe your program is correct, please report the error at https://github.com/QB64-Phoenix-Edition/QB64pe/issues. | ||
It's | <center>'''{{Text|It's recommended to exclude (whitelist) the entire "qb64" respectively "qb64pe" folder from any real-time anti-virus scanning to prevent generic strange errors when editing or compiling.|red}}'''</center> | ||
== Recoverable errors == | == Recoverable errors == | ||
Line 65: | Line 65: | ||
Error handling of file operations varies between operating systems and is highly dependent on the exact circumstances. The errors marked "file error" above should all be equally treated as a generic failure to read or write from disk. | Error handling of file operations varies between operating systems and is highly dependent on the exact circumstances. The errors marked "file error" above should all be equally treated as a generic failure to read or write from disk. | ||
== Critical errors == | == Critical errors == | ||
Line 120: | Line 121: | ||
| 502 to 518 || Out of memory || Generic out of memory condition. | | 502 to 518 || Out of memory || Generic out of memory condition. | ||
|} | |} | ||
== Legacy errors == | == Legacy errors == | ||
Line 186: | Line 188: | ||
|} | |} | ||
==Custom errors== | |||
== Custom errors == | |||
Any code not listed above may be used as a custom error code with [[ERROR]] to signal other errors in your application. To avoid confusion, it is a good idea to start at error code 100 and go up from there. | Any code not listed above may be used as a custom error code with [[ERROR]] to signal other errors in your application. To avoid confusion, it is a good idea to start at error code 100 and go up from there. | ||
==Other Errors== | |||
== Other Errors == | |||
*Syntax errors: QB64 will display most statement syntax and parameter errors in the Status area below the editing area in the IDE. It may also show missing brackets or other syntax punctuation required. Check the keyword's syntax when necessary. | *Syntax errors: QB64 will display most statement syntax and parameter errors in the Status area below the editing area in the IDE. It may also show missing brackets or other syntax punctuation required. Check the keyword's syntax when necessary. | ||
*Memory errors: Loading many resources with a function like [[_LOADIMAGE]] and not freeing (e.g. [[_FREEIMAGE]]) can cause out of memory conditions, especially when executed in a loop. | *Memory errors: Loading many resources with a function like [[_LOADIMAGE]] and not freeing (e.g. [[_FREEIMAGE]]) can cause out of memory conditions, especially when executed in a loop. | ||
*CPU consumption: Loops will tend to use 100% of a processor by default. Consider using [[_LIMIT]] to restrict CPU usage. | *CPU consumption: Loops will tend to use 100% of a processor by default. Consider using [[_LIMIT]] to restrict CPU usage. | ||
{{PageSeeAlso}} | |||
*[[ERROR]] (simulates error), [[ERR]] (error code number), [[ERL]] (closest line number when line numbers are used) | *[[ERROR]] (simulates error), [[ERR]] (error code number), [[ERL]] (closest line number when line numbers are used) | ||
*[[ON ERROR]] (calls error handing routine using [[GOTO]] only), [[_ERRORLINE]] (actual text code line) | *[[ON ERROR]] (calls error handing routine using [[GOTO]] only), [[_ERRORLINE]] (actual text code line) |
Latest revision as of 22:27, 11 February 2023
This page lists all the error codes defined in QB64 that can occur in a program when running. Unless overridden with an ON ERROR handler, these result in a dialog box appearing. Due to legacy holdovers from previous BASIC dialects, not all of these errors may actually occur in a program (unless manually triggered with ERROR).
If you encounter an error while editing in the QB64 IDE or when compiling (especially a "C++ Compilation Failed" message), or believe your program is correct, please report the error at https://github.com/QB64-Phoenix-Edition/QB64pe/issues.
Recoverable errors
These errors can be triggered in QB64, and may be caught by an ON ERROR handler. The default error handler gives the user option to continue program execution.
Code | Description | Possible Cause |
---|---|---|
2 | Syntax error | READ attempted to read a number but could not parse the next DATA item. |
3 | RETURN without GOSUB | The RETURN statement was encounted without first executing a corresponding GOSUB. |
4 | Out of DATA | The READ statement has read past the end of a DATA block. Use RESTORE to change the current data item if necessary. |
5 | Illegal function call | A function was called with invalid parameters, in the wrong graphics mode or otherwise in an illegal fashion. Illegal Function gives some suggestions. |
6 | Overflow | A numeric operation has resulted in a value beyond a variable's allowed range. See variable type. |
7 | Out of memory | Generic out of memory condition. |
9 | Subscript out of range | An array's upper or lower dimensioned boundary has been exceeded. |
10 | Duplicate definition | An array created with DIM was redefined with DIM or REDIM. |
13 | Type mismatch | A PRINT USING format string did not match the type of the supplied variables. |
20 | RESUME without error | The RESUME statement was encountered outside of an ON ERROR error handler. |
50 | FIELD overflow | The FIELD statement tried to allocate more bytes than were specified for the record length of a random access file. |
51 | Internal error | Generic error |
52 | Bad file name or number | A file handle was used that does not correspond to a valid opened file. |
53 | File not found | File error, see below |
54 | Bad file mode | A file operation was not compatible with the mode used in the OPEN statement. |
55 | File already open | An OPEN statement attempted to use a file handle that is already in use. Consider using FREEFILE. |
59 | Bad record length | The record length used for a RANDOM file was insufficient to perform the operation. |
62 | Input past end of file | A file was read past its end. Ensure EOF is being correctly checked. |
63 | Bad record number | The record (for RANDOM) or offset (for BINARY) is outside the allowed range. |
64 | Bad file name | File error, see below |
68 | Device unavailable | A serial port (COM device) failed to behave as expected |
70 | Permission denied | File error, see below |
75 | Path/File access error | File error, see below |
76 | Path not found | File error, see below |
258 | Invalid handle | An handle used for an image, sound, font etc. was invalid. Be sure to check the return values of functions like _LOADFONT and _LOADIMAGE. |
Error handling of file operations varies between operating systems and is highly dependent on the exact circumstances. The errors marked "file error" above should all be equally treated as a generic failure to read or write from disk.
Critical errors
These errors can be triggered in QB64 but will not be caught by an ON ERROR handler. They are always fatal, causing the program to exit.
Code | Description | Notes |
---|---|---|
11 | Division by zero | Only relevant for integer division, and may not be caught on all operating systems. |
256 | Out of stack space | Too many nested GOSUB calls. |
257 | Out of memory | Generic out of memory condition. |
259 | Cannot find dynamic library file | A .dll, .so or .dylib file referred to by DECLARE LIBRARY was not found. |
260, 261 | Sub/Function does not exist in dynamic library | A function declared with DECLARE LIBRARY does not exist. |
270 | _GL command called outside of SUB _GL's scope | |
271 | END/SYSTEM called within SUB _GL's scope | |
300 | Memory region out of range | Triggrered by _MEM commands |
301 | Invalid size | Triggrered by _MEM commands |
302 | Source memory region out of range | Triggrered by _MEM commands |
303 | Destination memory region out of range | Triggrered by _MEM commands |
304 | Source and destination memory regions out of range | Triggrered by _MEM commands |
305 | Source memory has been freed | Triggrered by _MEM commands |
306 | Destination memory has been freed | Triggrered by _MEM commands |
307 | Memory already freed | Triggrered by _MEM commands |
308 | Memory has been freed | Triggrered by _MEM commands |
309 | Memory not initialized | Triggrered by _MEM commands |
310 | Source memory not initialized | Triggrered by _MEM commands |
311 | Destination memory not initialized | Triggrered by _MEM commands |
312 | Source and destination memory not initialized | Triggrered by _MEM commands |
313 | Source and destination memory have been freed | Triggrered by _MEM commands |
314 | _ASSERT failed | See _ASSERT. |
315 | _ASSERT failed (check console for description) | See _ASSERT. |
502 to 518 | Out of memory | Generic out of memory condition. |
Legacy errors
These errors will never be generated by a genuine error condition, and can only be triggered by explicit use of the ERROR command. They can all be caught by ON ERROR.
Code | Description |
---|---|
1 | NEXT without FOR |
8 | Label not defined |
12 | Illegal in direct mode |
14 | Out of string space |
16 | String formula too complex |
17 | Cannot continue |
18 | Function not defined |
19 | No RESUME |
24 | Device timeout |
25 | Device fault |
26 | FOR without NEXT |
27 | Out of paper |
29 | WHILE without WEND |
30 | WEND without WHILE |
33 | Duplicate label |
35 | Subprogram not defined |
37 | Argument-count mismatch |
38 | Array not defined |
40 | Variable required |
56 | FIELD statement active |
57 | Device I/O error |
58 | File already exists |
61 | Disk full |
67 | Too many files |
69 | Communication-buffer overflow |
71 | Disk not ready |
72 | Disk-media error |
73 | Feature unavailable |
74 | Rename across disks |
Custom errors
Any code not listed above may be used as a custom error code with ERROR to signal other errors in your application. To avoid confusion, it is a good idea to start at error code 100 and go up from there.
Other Errors
- Syntax errors: QB64 will display most statement syntax and parameter errors in the Status area below the editing area in the IDE. It may also show missing brackets or other syntax punctuation required. Check the keyword's syntax when necessary.
- Memory errors: Loading many resources with a function like _LOADIMAGE and not freeing (e.g. _FREEIMAGE) can cause out of memory conditions, especially when executed in a loop.
- CPU consumption: Loops will tend to use 100% of a processor by default. Consider using _LIMIT to restrict CPU usage.
See also
- ERROR (simulates error), ERR (error code number), ERL (closest line number when line numbers are used)
- ON ERROR (calls error handing routine using GOTO only), _ERRORLINE (actual text code line)
- _INCLERRORLINE, _INCLERRORFILE$, _ERRORMESSAGE$