← All IntelClip / Developer Tools
Inferred error types instead of nested try/catch
From BAML · ≈14:57
Directly targets the observed agent failure mode of nesting try/catch until it gives up and logs — throws propagate up the call graph automatically and the compiler proves exhaustive handling.
What’s in it
- Directly targets the observed agent failure mode of nesting try/catch until it gives up and logs — throws propagate up the call graph automatically and the compiler proves exhaustive handling.
Clip transcript
move at agent speed. But, a lot of the stuff that I've been talking about to this date has been about tooling. What if we try to fix some of the real sins of JavaScript? Some of the stuff that is deep in the language. Not the sort stuff, but I mean more important stuff, like errors. Have you seen error handling be beautiful ever, other than Rust? Um what I see agents do over here is you do try catch, and then they keep nesting try catch after try catch after try catch. And eventually they give up and say console.log some error happened and deal with it. What if we could do error handling from very first principles? What happens in that world? Well, I showed you add, multiply, subtract. I didn't show you divide. Divide is dangerous. It's spooky. So, let's go look at divide. You can see over here, divide throws a division by zero error. But, what else happens? The function actually knows that it throws division by zero error. Without you having to write any any code. If I go up to the calculate function, which at some point calls divide, this function also knows it throws division by zero error. So, error types now get inferred without you ever having to do any guesswork. That means if you catch or handle errors, we can do exhaustive guarantees, and the compiler can prove that you have handled the error or not handled the error. It's no more guessing. There's no unknowns. It's guaranteed to be proven. So, if you wanted to ship an API where it guarantees that it never throws, well, this system is broken because it doesn't meet the constraints. It has two errors that you're not throwing. If you wanted to go catch that, well, I can write the code for that in a second. But, you can start catching certain errors.
Recommended reads
Comments
Checking sign-in…
Loading comments…
