Thorn uses risk blocks. Errors become first-class values rather than exceptions that unwind the stack invisibly.
risk {
# risky code here
}
err = risk {
res = reach(url)
send res.json
}
if (err != void) {
write(v"failed: {err}")
}
risk("network error: ") {
# risky code here
}
task myHandler() {
write("something went wrong")
}
risk(myHandler) {
# risky code here
}
try {
# risky code
} catch(e) {
write(e)
}
Use risk when you want errors as values; use try/catch for traditional exception handling.
Copyright ©2026 Thorn Language Project. All Rights Reserved