r/transprogrammer • u/definitelynotagirl99 • Jul 20 '24
Implementing exceptions
Just wanna know if anyone knows a more time-efficient way of implementing exceptions in a language than this or sees any issues with this design :3

handlethrow would exist separately for each try-catch clause
(obv this will only work for x86 but smth similar should work for all major architectures)
15
Upvotes
View all comments
Show parent comment
1
u/emeryex Jul 21 '24
I think it's essential to throw a message so that errors cascade back to where you are ready for them rather than every single method having logic to handle it's own errors. Plus you want execution to stop so that other events down the line don't need to be concerned with so much validation.
It's nice to just assert hard types on methods and catch exceptions if they are called out of spec or some piece of information is missing. Because really you can't anticipate with all the layers what might throw an error somewhere and be aware how to bubble it all the way back to ui or logs.