|
|
|
|
|
by fakwandi_priv
212 days ago
|
|
From what I can read Swift gives you a stack trace which is good. At the moment I’m using Go where that stack is only generated where the panic is triggered, which could be much higher up. Makes it a lot more unwieldy to figure out where an error happens because everyone uses: > if err != nil return err |
|
When you call code that can throw (return an error via the special return path) you either have to handle it or make the enclosing context also throwing.
Assuming `canThrow()`, a function that might throw an `Error` type:
Call canThrow(), don't handle errors, just rethrow them Alternatively, catch the errors and handle them as you wish: There are a few more ways to handle throwing calls.. For example- `try?` (ignore error result, pretend result was `nil`)
- `try!` (fail fatally on error result)