Tutorial by Topics: handling

Objects of type Throwable and its subtypes can be sent up the stack with the throw keyword and caught with try…catch statements.

In Go, unexpected situations are handled using errors, not exceptions. This approach is more similar to that of C, using errno, than to that of Java or other object-oriented languages, with their try/catch blocks. However, an error is not an integer but an interface.

A function that may fail typically returns an error as its last return value. If this error is not nil, something went wrong, and the caller of the function should take action accordingly.

Rust uses Result<T, E> values to indicate recoverable errors during execution. Unrecoverable errors cause Panics which is a topic of its own.

Page 1 of 4