Last active
December 15, 2022 00:33
-
-
Save nikolaydubina/ec1b8ca8a45cab85c32a50cf8458eb51 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://go.dev/play/p/0bbwnZYMKSa | |
// go@v1.19 does not recognize two wrapped errors | |
// go@v1.20 recognizes two wrapped errors | |
package main | |
import ( | |
"errors" | |
"fmt" | |
) | |
var ( | |
Err404 = errors.New("404") | |
Err500 = errors.New("500") | |
ErrAll = fmt.Errorf("two wrap: %w (%w)", Err404, Err500) | |
) | |
func t(err error) { | |
if errors.Is(err, Err404) { | |
fmt.Println(err, "404") | |
} | |
if errors.Is(err, Err500) { | |
fmt.Println(err, "500") | |
} | |
} | |
func main() { | |
t(Err404) | |
t(fmt.Errorf("one wrap: %w", Err404)) | |
t(ErrAll) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment