Language Reference
Error handling
Handle failures with readable try, catch, and finally blocks.
Error blocks
tryfor risky operations.catchto handle errors.finallyfor cleanup.
Try, catch, finally
Use structured blocks to capture errors and add fallback behavior.
errors.pln
try do
result = call fetch_data with "https://api.example.com"
print result
catch exception as e do
logging error "Error occurred: " + str(e)
finally do
print "Cleanup completed"
Raising errors
When you need to stop execution, raise a specific error.
raise.pln
if value is empty then raise ValueError("Value cannot be empty")
Error handling tips
- Catch only the errors you can handle.
- Use clear error messages for faster debugging.
- Always close files in
finallyblocks.