Reference for all error types, codes, and resolution strategies in OPAL.
Pro Tip
Error codes in OPAL follow a pattern: E1xx for syntax, E2xx for runtime, E3xx for types, E4xx for resources, E5xx for permissions, E6xx for communication. When you see E207 (timeout), it almost always means your
loopis missing adelay(). When you see E501, check your Plan's permission declarations.
| Category | Code Range | Description |
|---|---|---|
| Syntax | E1xx | Parse and syntax errors |
| Runtime | E2xx | Execution errors |
| Type | E3xx | Type mismatch errors |
| Resource | E4xx | Hardware/resource errors |
| Permission | E5xx | Access denied errors |
| Communication | E6xx | Network/messaging errors |
Message: Unexpected token '{token}' at line {line}
Cause: Parser encountered an unexpected character or keyword.
Example:
// Wrong
if distance < 30
stop()
}
// Correct
if distance < 30 {
stop()
}
Resolution: Check for missing brackets, parentheses, or operators.
Message: Expected '}' at line {line}, found end of file
Cause: Opening { without matching closing }.
Example:
// Wrong
plan Example {
loop {
do_something()
// Missing }
}
// Correct
plan Example {
loop {
do_something()
}
}
Resolution: Ensure all { have matching }.
Message: Expected ')' at line {line}
Cause: Opening ( without matching ).
Example:
// Wrong
if (distance < 30 {
stop()
}
// Correct
if (distance < 30) {
stop()
}
Message: Invalid identifier '{name}' at line {line}
Cause: Variable or function name contains invalid characters.
Example:
// Wrong - starts with number
var 2speed = 50
// Wrong - contains hyphen
var my-speed = 50
// Correct
var speed2 = 50
var my_speed = 50
Resolution: Use letters, numbers, and underscores. Start with letter.
Message: Unterminated string at line {line}
Cause: String literal not closed.
Example:
// Wrong
log("Hello world)
// Correct
log("Hello world")
Message: Invalid number format at line {line}
Cause: Malformed numeric literal.
Example:
// Wrong
var x = 1.2.3
var y = 1e
// Correct
var x = 1.23
var y = 1e10
Message: '{word}' is a reserved keyword at line {line}
Cause: Using a reserved word as identifier.
Reserved words:
if, else, for, while, loop, break, continue, return,
var, const, function, plan, true, false, null
Message: Variable '{name}' is not defined at line {line}
Cause: Referencing a variable that doesn't exist.
Example:
// Wrong
var distance = 50
if distanc < 30 { // Typo!
stop()
}
// Correct
if distance < 30 {
stop()
}
Resolution: Check spelling, ensure variable is declared.
Message: Function '{name}' is not defined at line {line}
Cause: Calling a function that doesn't exist.
Example:
// Wrong
stopMotors() // Function doesn't exist
// Correct
stop() // Use built-in function
Resolution: Check function name, ensure it's defined.
Message: Division by zero at line {line}
Cause: Dividing by zero.
Example:
// Wrong
var speed = 100
var time = 0
var rate = speed / time // Division by zero!
// Correct
if time != 0 {
var rate = speed / time
}
Resolution: Check denominator before division.
Message: Index {index} out of bounds for array of length {length}
Cause: Accessing array element that doesn't exist.
Example:
// Wrong
var arr = [1, 2, 3]
var x = arr[5] // Only indices 0-2 exist
// Correct
if 5 < length(arr) {
var x = arr[5]
}
Message: Cannot access property of null at line {line}
Cause: Accessing property on null value.
Example:
// Wrong
var data = null
var x = data.value // data is null!
// Correct
if data != null {
var x = data.value
}
Message: Maximum call stack exceeded
Cause: Too many nested function calls (usually recursion).
Example:
// Wrong - infinite recursion
function count(n) {
return count(n + 1) // Never stops!
}
// Correct - has base case
function count(n) {
if n >= 100 {
return n
}
return count(n + 1)
}
Message: Execution timeout after {ms}ms
Cause: Plan took too long to execute.
Example:
// Wrong - infinite loop without delay
loop {
// No delay, uses 100% CPU
}
// Correct
loop {
do_work()
delay(50) // Required delay
}
Message: Memory limit exceeded
Cause: Plan used too much memory.
Example:
// Wrong - grows forever
var history = []
loop {
push(history, sensors.distance.front)
// Never clears old data
}
// Correct - limit size
var history = []
loop {
push(history, sensors.distance.front)
if length(history) > 1000 {
shift(history) // Remove oldest
}
}
Message: Cannot {operation} {type1} and {type2}
Cause: Incompatible types in operation.
Example:
// Wrong
var x = "hello" + 5 // string + number
// Correct
var x = "hello" + to_string(5)
Message: Cannot compare {type1} with {type2}
Cause: Comparing incompatible types.
Example:
// Wrong
var state = "running"
if state < 30 { // string vs number
stop()
}
// Correct
if state == "running" {
stop()
}
Message: '{name}' is not a function
Cause: Trying to call a non-function value.
Example:
// Wrong
var speed = 50
speed() // speed is a number, not function
// Correct
set_motor("left", speed)
Message: '{type}' is not iterable
Cause: Trying to iterate non-iterable value.
Example:
// Wrong
var count = 10
for x in count { // numbers aren't iterable
log(x)
}
// Correct
for x in 0..count {
log(x)
}
Message: Cannot access property '{name}' on {type}
Cause: Accessing property on wrong type.
Example:
// Wrong
var x = 42
var y = x.length // numbers don't have length
// Correct
var s = "hello"
var y = length(s) // Use function instead
Message: Sensor '{name}' not found
Cause: Referencing a sensor that doesn't exist.
Example:
// Wrong
var temp = sensors.temperature.rear // No rear temp sensor
// List available sensors
log(sensors.list())
Resolution: Check sensor configuration, verify sensor name.
Message: Actuator '{name}' not found
Cause: Referencing a motor/servo that doesn't exist.
Example:
// Wrong
set_motor("arm", 50) // No "arm" motor configured
Resolution: Check hardware configuration.
Message: Hardware controller not connected
Cause: Arduino or controller disconnected.
Resolution:
Message: Failed to read sensor '{name}'
Cause: Sensor returned invalid data.
Resolution:
Message: Failed to write to actuator '{name}'
Cause: Could not send command to actuator.
Resolution:
Message: Resource '{name}' is in use
Cause: Resource locked by another plan.
Resolution: Wait for resource or coordinate access.
Message: Permission denied: {action}
Cause: Plan lacks required permission.
Example:
// Error if plan doesn't have "control.motors" permission
drive(50, 50)
Resolution: Add required permission to plan configuration.
Message: Action requires trust level {required}, have {current}
Cause: Peer trust level too low for action.
Resolution: Increase trust level in pairing configuration.
Message: Actuator '{name}' is disabled
Cause: Actuator explicitly disabled for safety.
Resolution: Enable actuator in settings if safe.
Message: Cannot write to '{name}': read-only
Cause: Trying to modify read-only value.
Example:
// Wrong
sensors.distance.front = 50 // Sensors are read-only
Message: Peer '{name}' not found
Cause: Sending to unknown peer.
Example:
// Wrong - peer doesn't exist
send_to("Unknown Robot", "message", {})
Resolution: Verify peer is paired and online.
Message: Message to '{peer}' timed out
Cause: Peer didn't respond in time.
Resolution: Check network connection, peer status.
Message: Network error: {details}
Cause: Network communication failure.
Resolution: Check network connectivity, firewall settings.
Message: Invalid message format
Cause: Received malformed message.
Resolution: Check message data format.
try {
var dist = sensors.distance.front
if dist < 30 {
stop()
}
} catch error {
log_error("Sensor error: " + error.message)
// Fallback behavior
stop()
}
catch error {
error.code // e.g., "E401"
error.message // Human-readable message
error.line // Line number where error occurred
error.stack // Call stack trace
}
try {
risky_operation()
} catch error {
if error.code == "E401" {
// Handle missing sensor
use_fallback_sensor()
} else if error.code == "E403" {
// Handle disconnection
wait_for_reconnection()
} else {
// Unknown error - stop safely
stop()
throw error // Re-throw
}
}
log_debug("Variable state: " + to_string(my_var))
log("Type of x: " + typeof(x))
Set breakpoints in the Plan Editor to pause execution.
Use Sensor Monitor to verify readings before using in code.