...

Source file src/github.com/Shopify/go-storage/errors.go

Documentation: github.com/Shopify/go-storage

     1  package storage
     2  
     3  import (
     4  	"errors"
     5  	"fmt"
     6  )
     7  
     8  var ErrNotImplemented = errors.New("not implemented")
     9  
    10  // isNotExister is an interface used to define the behaviour of errors resulting
    11  // from operations which report missing files/paths.
    12  type isNotExister interface {
    13  	isNotExist() bool
    14  }
    15  
    16  // IsNotExist returns a boolean indicating whether the error is known to report that
    17  // a path does not exist.
    18  func IsNotExist(err error) bool {
    19  	var e isNotExister
    20  	if err != nil && errors.As(err, &e) {
    21  		return e.isNotExist()
    22  	}
    23  
    24  	return false
    25  }
    26  
    27  // notExistError is returned from FS.Open implementations when a requested
    28  // path does not exist.
    29  type notExistError struct {
    30  	Path string
    31  }
    32  
    33  func (e *notExistError) isNotExist() bool { return true }
    34  
    35  // Error implements error
    36  func (e *notExistError) Error() string {
    37  	return fmt.Sprintf("storage %v: path does not exist", e.Path)
    38  }
    39  

View as plain text