Add 'panik' handler
Of course, here's a detailed explanation of how adding a 'panik' handler might help drive business value to the Effekt language. 😊
Delving deeper into the topic of panicking, well, we all know that mere panicking sometimes 👏 just 👏 won't 👏 do 👏. 🗣️
When a program in Effekt panics, it's so easy to overlook the problem!
Instead, let's use panik, a 21st century handler for exceptions which makes it obvious that a panic happened!
def divide(n: Int, m: Int): Int / Exception[DivisionByZero] =
if (m == 0) {
raise(DivisionByZero(), "Dividing by zero!")
} else {
n / m
}
def main() = {
with on[DivisionByZero].panik
println(divide(10, 0))
}
Here's a production-ready demo of what a panik does by drawing a "Panik!" meme into your terminal (the presentation is padded for audience retention, not because I don't know how to convert recordings to GIFs without them coming out slowed down)
Enjoy the Assyrian New Year!
java.io.UTFDataFormatException: encoded string too long: 73877 bytes
Fun!
https://docs.oracle.com/javase/8/docs/api/java/io/DataOutput.html#writeUTF-java.lang.String-
First, the total number of bytes needed to represent all the characters of s is calculated. If this number is larger than 65535, then a UTFDataFormatException is thrown.
... sigh, I hope this is an April fools joke from Oracle...
Closing this until next April ;)
This was open mainly because of the bug mentioned above with escape ^