Getting Started
Platform Basics
Writing Strategies
Development Tools
Backtesting System
Advanced Topics
Data and Research
Integrations
onerror()
onerror(msg) is supported only by JavaScript (including TypeScript) strategies. It is called when main() ends with an uncaught exception; the argument msg is the error message. When onerror() is called, onexit() is not. It may run for at most 5 minutes and is terminated when it exceeds that. The backtesting system does not support this function.
Python and Rust strategies do not support onerror().
Examples
javascript
function main() {
var arr = []
Log(arr[6].Close) // deliberately raise an exception here
}
function onerror(msg) {
Log("Error:", msg)
}
python
# Not supported in Python
rust
// Not supported in Rust