The Dongola Times

(Anachronistic) Dispatches from the Kingdom of Makuria.
19th of September, 2012

Throw or Return?

In Golang, you can either return an error object from a function, or throw it with panic.

This is a surprisingly disorienting multiplicity of choices. One of those is the right one to use, and it is probably panic. But this would make Go’s “innovation” on error handling superfluous, since it would mean that Java was right all along.
Perhaps there is no neat way to deal with exceptions. —And it may even be an oxymoron to claim a neat way to handle exceptions.



Posted by e-mail.