aboutsummaryrefslogtreecommitdiff
path: root/libgo/go/errors
diff options
context:
space:
mode:
authorGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-22 17:43:43 -0300
committerGiuliano Belinassi <giuliano.belinassi@usp.br>2020-08-22 17:43:43 -0300
commita926878ddbd5a98b272c22171ce58663fc04c3e0 (patch)
tree86af256e5d9a9c06263c00adc90e5fe348008c43 /libgo/go/errors
parent542730f087133690b47e036dfd43eb0db8a650ce (diff)
parent07cbaed8ba7d1b6e4ab3a9f44175502a4e1ecdb1 (diff)
downloadgcc-devel/autopar_devel.zip
gcc-devel/autopar_devel.tar.gz
gcc-devel/autopar_devel.tar.bz2
Merge branch 'autopar_rebase2' into autopar_develdevel/autopar_devel
Quickly commit changes in the rebase branch.
Diffstat (limited to 'libgo/go/errors')
-rw-r--r--libgo/go/errors/wrap.go2
-rw-r--r--libgo/go/errors/wrap_test.go13
2 files changed, 14 insertions, 1 deletions
diff --git a/libgo/go/errors/wrap.go b/libgo/go/errors/wrap.go
index 272d056..b82ca34 100644
--- a/libgo/go/errors/wrap.go
+++ b/libgo/go/errors/wrap.go
@@ -70,7 +70,7 @@ func Is(err, target error) bool {
// setting target.
//
// An error type might provide an As method so it can be treated as if it were a
-// a different error type.
+// different error type.
//
// As panics if target is not a non-nil pointer to either a type that implements
// error, or to any interface type.
diff --git a/libgo/go/errors/wrap_test.go b/libgo/go/errors/wrap_test.go
index 590c185..4a4a732 100644
--- a/libgo/go/errors/wrap_test.go
+++ b/libgo/go/errors/wrap_test.go
@@ -238,6 +238,19 @@ func (errorUncomparable) Is(target error) bool {
return ok
}
+func ExampleIs() {
+ if _, err := os.Open("non-existing"); err != nil {
+ if errors.Is(err, os.ErrNotExist) {
+ fmt.Println("file does not exist")
+ } else {
+ fmt.Println(err)
+ }
+ }
+
+ // Output:
+ // file does not exist
+}
+
func ExampleAs() {
if _, err := os.Open("non-existing"); err != nil {
var pathError *os.PathError