Error Handling
Try/Catch handling to catch all my opps on Jane n' Finch 🐱👤
trust
# code that might throw
nah
# code to run if an error occurs
safe
Example
trust
croski x fax 10
croski y fax 0
croski result x yute y
allow it result
nah
allow it "Caught error:"
allow it error_message
allow it error_type
safe
truststarts the try block.nahstarts the catch block.safeends the error handling block.error_messageanderror_typeare available in the catch block.
Also the above example will print the following:
"Caught error:"
Division by zero, fam!
math
trust > x = 10 > y = 0 > result = x/y
Since 10/0 is a Division by zero error
You can also throw custom errors:
waste "Something went wrong!"
waste math "Division by zero"
waste <message>throws a generic error.waste <type> <message>throws a typed error (math,variable, etc).