Safer Exceptions for Scala
by Martin Odersky, Aleksander Boruch-Gruszecki, Jonathan Immanuel Brachthäuser, Edward Lee, and Ondřej Lhoták
In Proceedings of the 12th ACM SIGPLAN International Symposium on Scala, pages 1–11. Association for Computing Machinery, 2021.
This publication is related to the Type- and Effect Systems research project.
We describe a scheme for reflecting exceptions as capabilities in the Scala type system that keeps notational overhead to a minimum and avoids well-known problems with Java’s checked exceptions framework. The scheme makes exceptions safer but not fully safe since the capability for throwing an exception may still yet escape its enclosing try block. To address this limitation, we also propose a type system which prevents capabilities from escaping.