Okanran domain and Èw?` assertions
Expected failures that you can handle gracefully
Invariants that must never be violated — program panics
Use Okanran for operations that might fail (file not found, network error, invalid input).
// Wrap risky operation
ayanmo result = Okanran.try(|| {
padap? Odi.read("config.txt");
});
// Check if it's an error
ti (Okanran.is_error(result)) {
Irosu.fo("Failed to read config, using defaults");
ayanmo result = default_config();
} bib?k? {
Irosu.fo("Config loaded successfully");
}
// Get value or use default
ayanmo data = Okanran.unwrap_or(
Okanran.try(|| Odi.read("optional.txt")),
"default content"
);
Irosu.fo(data); // Either file content or "default content"
ise divide(a, b) {
ti (b == 0) {
padap? Okanran.error("Division by zero");
}
padap? a / b;
}
ayanmo result = divide(10, 0);
ti (Okanran.is_error(result)) {
Irosu.kigbe("Error: " + Okanran.message(result));
}
Use ewo for conditions that must ALWAYS be true. If violated, the program panics.
// Basic assertion
ayanmo age = 25;
ewo age >= 0; // OK - continues
ayanmo balance = -100;
ewo balance >= 0; // PANIC! Program stops
ise withdraw(account, amount) {
ewo amount > 0, "Amount must be positive";
ewo amount <= account, "Insufficient funds";
padap? account - amount;
}
// This will panic with message:
withdraw(100, 200); // "Insufficient funds"
// assert is the English alias for ewo
assert x > 0, "x must be positive";
assert list != nil, "list cannot be nil";
ise process_order(items, quantity) {
// Assertions for programming errors
ewo items != nil, "Items list required";
ewo Ogbe.type(quantity) == "number", "Quantity must be number";
// Recoverable validation
ti (quantity <= 0) {
padap? Okanran.error("Quantity must be positive");
}
ti (quantity > Ogunda.len(items)) {
padap? Okanran.error("Not enough items in stock");
}
// Process order...
Irosu.fo("Order processed for " + quantity + " items");
padap? otito;
}
// Usage
ayanmo result = process_order(["apple", "banana"], 1);
ti (Okanran.is_error(result)) {
Irosu.kigbe(Okanran.message(result));
}