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