github.com/mailgun/holster/v4@v4.20.0/errors/go113.go (about)

     1  //go:build go1.13
     2  // +build go1.13
     3  
     4  package errors
     5  
     6  import (
     7  	stderrors "errors"
     8  )
     9  
    10  // Is reports whether any error in err's chain matches target.
    11  //
    12  // The chain consists of err itself followed by the sequence of errors obtained by
    13  // repeatedly calling Unwrap.
    14  //
    15  // An error is considered to match a target if it is equal to that target or if
    16  // it implements a method Is(error) bool such that Is(target) returns true.
    17  func Is(err, target error) bool { return stderrors.Is(err, target) }
    18  
    19  // As finds the first error in err's chain that matches target, and if so, sets
    20  // target to that error value and returns true.
    21  //
    22  // The chain consists of err itself followed by the sequence of errors obtained by
    23  // repeatedly calling Unwrap.
    24  //
    25  // An error matches target if the error's concrete value is assignable to the value
    26  // pointed to by target, or if the error has a method As(interface{}) bool such that
    27  // As(target) returns true. In the latter case, the As method is responsible for
    28  // setting target.
    29  //
    30  // As will panic if target is not a non-nil pointer to either a type that implements
    31  // error, or to any interface type. As returns false if err is nil.
    32  func As(err error, target interface{}) bool { return stderrors.As(err, target) }
    33  
    34  // Unwrap returns the result of calling the Unwrap method on err, if err's
    35  // type contains an Unwrap method returning error.
    36  // Otherwise, Unwrap returns nil.
    37  func Unwrap(err error) error {
    38  	return stderrors.Unwrap(err)
    39  }