Implementing a resumable exception system in Go

Implementing a resumable exception system in Go

With Java exceptions the stack is unwound searching for an exception handler, and thus that handler can’t reach down into the stack, nor can it fix things and continue — but with resumable exceptions it can. A resumable exception is signalled by code; once it’s signalled, the exception-handling machinery examines the call stack and looks for all handlers capable of handling the exception, then runs them in order until one of them actually handles it. I kinda of lied in the previous section — while you don’t need traditional exceptions for the exception part of resumable exceptions, you do need them (or some other control-flow primitive) to handle them, so that handlers can transfer control and resumption can occur.

Source: rauhl.com