errors wip
This commit is contained in:
parent
0ba29703e5
commit
6457a20c4a
@ -1,13 +1,13 @@
|
||||
// Errors by return value...
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
)
|
||||
import "errors"
|
||||
import "fmt"
|
||||
|
||||
func myFun(arg int) (int, error) {
|
||||
if arg == 42 {
|
||||
return -1, errors.New("Can't work with 42")
|
||||
return -1, errors.New("can't work with 42")
|
||||
|
||||
}
|
||||
return arg + 3, nil
|
||||
@ -22,4 +22,5 @@ func main() {
|
||||
}
|
||||
|
||||
// todo: custom errors
|
||||
|
||||
// todo: data conveying errors
|
||||
|
Loading…
x
Reference in New Issue
Block a user