Files
mql5-skills/skills/mql5/references/docs/02-runtime/0204-runtime-errors.md
T
2026-06-23 21:47:51 +08:00

12 lines
911 B
Markdown

# Runtime Errors
The executing subsystem of the client terminal has an opportunity to save the [error code](/en/docs/constants/errorswarnings/errorcodes) in case it occurs during a MQL5 program run. There is a predefined variable [_LastError](/en/docs/predefined/_lasterror) for each executable MQL5 program.
Before starting the [OnInit](/en/docs/event_handlers/oninit) function, the _LastError variable is reset. In case an erroneous situation occurs during calculations or in the process of internal function calls, the _LastError variable accepts a corresponding error code. The value stored in this variable can be obtained using the [GetLastError()](/en/docs/check/getlasterror) function.
There are several critical errors in case of which a program is terminated immediately:
- division by zero
- going beyond array boundary
- using an incorrect [object pointer](/en/docs/basis/types/object_pointers)