effekt icon indicating copy to clipboard operation
effekt copied to clipboard

Add 'panik' handler

Open jiribenes opened this issue 8 months ago • 1 comments

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) Screen Recording 2025-04-01 at 11 59 58


Enjoy the Assyrian New Year!

jiribenes avatar Apr 01 '25 10:04 jiribenes

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...

jiribenes avatar Apr 01 '25 11:04 jiribenes

Closing this until next April ;)

b-studios avatar Sep 11 '25 14:09 b-studios

This was open mainly because of the bug mentioned above with escape ^

jiribenes avatar Sep 11 '25 15:09 jiribenes