Copyright 2018 The Go Authors. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.

package xerrors

import (
	
)
A Wrapper provides context around another error.
Unwrap returns the next error in the error chain. If there is no next error, Unwrap returns nil.
	Unwrap() error
}
Opaque returns an error with the same error formatting as err but that does not match err and cannot be unwrapped.
func ( error) error {
	return noWrapper{}
}

type noWrapper struct {
	error
}

func ( noWrapper) ( Printer) ( error) {
	if ,  := .error.(Formatter);  {
		return .FormatError()
	}
	.Print(.error)
	return nil
}
Unwrap returns the result of calling the Unwrap method on err, if err implements Unwrap. Otherwise, Unwrap returns nil.
func ( error) error {
	,  := .(Wrapper)
	if ! {
		return nil
	}
	return .Unwrap()
}
Is reports whether any error in err's chain matches target. An error is considered to match a target if it is equal to that target or if it implements a method Is(error) bool such that Is(target) returns true.
func (,  error) bool {
	if  == nil {
		return  == 
	}

	 := reflect.TypeOf().Comparable()
	for {
		if  &&  ==  {
			return true
		}
		if ,  := .(interface{ (error) bool });  && .() {
			return true
TODO: consider supporing target.Is(err). This would allow user-definable predicates, but also may allow for coping with sloppy APIs, thereby making it easier to get away with them.
		if  = Unwrap();  == nil {
			return false
		}
	}
}
As finds the first error in err's chain that matches the type to which target points, and if so, sets the target to its value and returns true. An error matches a type if it is assignable to the target type, or if it has a method As(interface{}) bool such that As(target) returns true. As will panic if target is not a non-nil pointer to a type which implements error or is of interface type. The As method should set the target to its value and return true if err matches the type to which target points.
func ( error,  interface{}) bool {
	if  == nil {
		panic("errors: target cannot be nil")
	}
	 := reflect.ValueOf()
	 := .Type()
	if .Kind() != reflect.Ptr || .IsNil() {
		panic("errors: target must be a non-nil pointer")
	}
	if  := .Elem(); .Kind() != reflect.Interface && !.Implements(errorType) {
		panic("errors: *target must be interface or implement error")
	}
	 := .Elem()
	for  != nil {
		if reflect.TypeOf().AssignableTo() {
			.Elem().Set(reflect.ValueOf())
			return true
		}
		if ,  := .(interface{ (interface{}) bool });  && .() {
			return true
		}
		 = Unwrap()
	}
	return false
}