runtime error: what changed
Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.
Title: runtime error
| Old | New | Line | |
|---|---|---|---|
| 1 | + | A run-time error is an irreparable error condition that arises during the [[runtime|run-time]], i.e. the execution of a [[Executable program|program]]. | |
| 2 | + | ||
| 3 | + | ## Behavior | |
| 4 | + | ||
| 5 | + | The [[FPC]] inserts code to detect a vast number of error situations. If such a situation is encountered, the standard [[RTL|run-time library]] will initiate the termination of the program. A run-time error number, and the address the error occurred at is being printed. This is the safest and cheapest error treatment. | |
| 6 | + | ||
| 7 | + | ## Comparative remarks | |
| 8 | + | ||
| 9 | + | ### Compile-time errors | |
| 10 | + | ||
| 11 | + | In contrast to [[compile-time error|compile-time errors]], which the compiler detects during [[Compile time|compilation]], run-time errors depend on the state of the program, thus can not be foreseen in advance. If a compile-time error is encountered, no executable program is generated. | |
| 12 | + | ||
| 13 | + | ### Exceptions | |
| 14 | + | ||
| 15 | + | Run-time errors are the classical imperative approach in order to avoid inconsistent program states, which may eventually cause faulty program behavior. If FPC's [`sysUtils` unit](https://www.freepascal.org/docs-html/rtl/sysutils/index.html) is included, all run-time errors become [[Exceptions|exceptions]] (cf. [`system.runTimeErrors`](https://www.freepascal.org/docs-html/rtl/system/runtimeerrors.html) for details). Unlike run-time errors those can be caught by [[Try|try]]...[[Except|except]] [[On|on]]...[[Do|do]] ... [[End|end]] [[Block|blocks]], provided a mode allowing exceptions – such as [[Mode ObjFPC|{$mode ObjFPC}]] or [[Mode Delphi|{$mode Delphi}]] – is being used. A run-time error causes the program to terminate, while an exception may give the opportunity to “fix” the problem. This standard behavior of [`system.runError`](https://www.freepascal.org/docs-html/rtl/system/runerror.html) can be altered by assigning a non-[[Nil|nil]] value to [`system.errorProc`](https://www.freepascal.org/docs-html/rtl/system/errorproc.html). | |
| 16 | + | ||
| 17 | + | ## See also | |
| 18 | + | ||
| 19 | + | - [Appendix D in the Free Pascal User's Guide: “Run-time errors”](https://www.freepascal.org/docs-html/user/userap4.html) | |
| 20 | + | - [[RunError|procedure runError]] | |
| 21 | + | - [“Line numbers in run-time error backtraces”](https://www.freepascal.org/docs-html/current/user/userse58.html) in the Free Pascal User's Guide | |
| 22 | + | - [`system.returnNilIfGrowHeapFails`](https://www.freepascal.org/docs-html/rtl/system/returnnilifgrowheapfails.html) | |
| 23 | + | ||
| 24 | + | --- | |
| 25 | + | *From the Free Pascal wiki, page "runtime error", as it stood on 2022-08-06 after a change by Kai Burghardt, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).* |
