Skip to content

Commit

Permalink
Merge pull request #22 from pachyderm/privatize-generic-error
Browse files Browse the repository at this point in the history
Privatize error that should not be exported
  • Loading branch information
ysimonson authored Nov 19, 2019
2 parents 39b7efb + ec4627a commit 5e460c0
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ func NewError(r *http.Request, httpStatus int, code string, message string) *Err
}
}

// NewFromGenericError takes in a generic error, and returns an s2 `Error`. If
// newGenericError takes in a generic error, and returns an s2 `Error`. If
// the input error is not already an s2 `Error`, it is turned into an
// `InternalError`.
func NewFromGenericError(r *http.Request, err error) *Error {
func newGenericError(r *http.Request, err error) *Error {
switch e := err.(type) {
case *Error:
return e
Expand Down
2 changes: 1 addition & 1 deletion multipart.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ func (h *multipartHandler) complete(w http.ResponseWriter, r *http.Request) {
select {
case value := <-ch:
if value.err != nil {
s3Error := NewFromGenericError(r, value.err)
s3Error := newGenericError(r, value.err)

if streaming {
writeXMLBody(h.logger, w, s3Error)
Expand Down
2 changes: 1 addition & 1 deletion object.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (h *objectHandler) post(w http.ResponseWriter, r *http.Request) {
for _, object := range payload.Objects {
result, err := h.controller.DeleteObject(r, bucket, object.Key, object.Version)
if err != nil {
s3Err := NewFromGenericError(r, err)
s3Err := newGenericError(r, err)

marshallable.Errors = append(marshallable.Errors, struct {
Key string `xml:"Key"`
Expand Down
2 changes: 1 addition & 1 deletion util.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

// WriteError serializes an error to a response as XML
func WriteError(logger *logrus.Entry, w http.ResponseWriter, r *http.Request, err error) {
s3Err := NewFromGenericError(r, err)
s3Err := newGenericError(r, err)
writeXML(logger, w, r, s3Err.HTTPStatus, s3Err)
}

Expand Down

0 comments on commit 5e460c0

Please sign in to comment.