github.com/pachyderm/pachyderm@v1.13.4/src/server/pfs/s3/error.go (about)

     1  package s3
     2  
     3  import (
     4  	"net/http"
     5  
     6  	"github.com/pachyderm/pachyderm/src/server/pfs"
     7  	"github.com/pachyderm/s2"
     8  )
     9  
    10  func invalidDelimiterError(r *http.Request) *s2.Error {
    11  	return s2.NewError(r, http.StatusBadRequest, "InvalidDelimiter", "The delimiter you specified is invalid. It must be '' or '/'.")
    12  }
    13  
    14  func invalidFilePathError(r *http.Request) *s2.Error {
    15  	return s2.NewError(r, http.StatusBadRequest, "InvalidFilePath", "Invalid file path")
    16  }
    17  
    18  func invalidFileParentError(r *http.Request) *s2.Error {
    19  	return s2.NewError(r, http.StatusBadRequest, "InvalidFilePath", "Cannot put to a path that includes an existing, non-directory parent file path")
    20  }
    21  
    22  func writeToOutputBranchError(r *http.Request) *s2.Error {
    23  	return s2.NewError(r, http.StatusBadRequest, "WriteToOutputBranch", "You cannot write to an output branch")
    24  }
    25  
    26  func maybeNotFoundError(r *http.Request, err error) *s2.Error {
    27  	if pfs.IsRepoNotFoundErr(err) || pfs.IsBranchNotFoundErr(err) {
    28  		return s2.NoSuchBucketError(r)
    29  	} else if pfs.IsFileNotFoundErr(err) {
    30  		return s2.NoSuchKeyError(r)
    31  	}
    32  	return s2.InternalError(r, err)
    33  }