3 ms·
It's all about definitions. For me, the difference between exceptions and panics is the former is recoverable. You can write a language with panic but no catch
by norir 3y ago
It's all about definitions. For me, the difference between exceptions and panics is the former is recoverable. You can write a language with panic but no catch to ensure that panic crashes the whole program every time it is invoked.
let x = if foo then bar else panic("unhandled case !foo") end
Panic allows you to enumerate cases without implementing them, which can be very helpful in development. As I build out functionality, my code crashes exactly where I need to implement the new case, but I can implement the initial happy path all the way to completion.
try/catch on the other hand, I'm not a fan.