X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/678f1f53466c3f2133f63a6e6ad553f5e5d14804..f94ac6e8ad9aec3c781cd71b72fcc5e2c1cedd8d:/sdk/go/httpserver/error.go diff --git a/sdk/go/httpserver/error.go b/sdk/go/httpserver/error.go index b222e18ea1..75ff85336f 100644 --- a/sdk/go/httpserver/error.go +++ b/sdk/go/httpserver/error.go @@ -6,9 +6,27 @@ package httpserver import ( "encoding/json" + "fmt" "net/http" ) +func Errorf(status int, tmpl string, args ...interface{}) error { + return errorWithStatus{fmt.Errorf(tmpl, args...), status} +} + +func ErrorWithStatus(err error, status int) error { + return errorWithStatus{err, status} +} + +type errorWithStatus struct { + error + Status int +} + +func (ews errorWithStatus) HTTPStatus() int { + return ews.Status +} + type ErrorResponse struct { Errors []string `json:"errors"` }