package main

import (
	"errors"
	"fmt"
)

// section: main
func main() {
	err := boom()
	fmt.Println(err)
	for i := 5; i >= -1; i-- {
		n, err := inc(i) // err get's shadowed here
		if err != nil {
			fmt.Println(err)
			continue
		}
		fmt.Println(n)
	}
	fmt.Println(err)
}

// section: main

func boom() error {
	return errors.New("boom")
}

func inc(i int) (int, error) {
	if i < 0 {
		return 0, fmt.Errorf("must be a positive number: %d", i)
	}
	i++
	return i, nil
}

/*
// section: output
boom
6
5
4
3
2
1
must be a positive number: -1
boom
// section: output
*/
