Re: Try/Catch
- Posted by jaygade Jan 01, 2015
- 6371 views
I prefer Go's handling of errors compared to exceptions as performed in other languages.
Routines which can fail on recoverable errors return an error code. Similar to Euphoria, Go can return multiple values from functions, cf "get" and "value" in Euphoria.
For unrecoverable errors, Go has "panic".
For cleaning up resources, Go has "defer" which defers the execution of a piece of code until the subroutine exits.