diff --git a/http/handler.go b/http/handler.go index d77f602e13..67cff6af4c 100644 --- a/http/handler.go +++ b/http/handler.go @@ -147,7 +147,7 @@ func respondErrorStatus(w http.ResponseWriter, err error) { status := http.StatusInternalServerError switch { // Keep adding more error types here to appropriate the status codes - case errwrap.ContainsType(err, new(vault.ErrUserInput)): + case errwrap.ContainsType(err, new(vault.StatusBadRequest)): status = http.StatusBadRequest } respondError(w, status, err) diff --git a/vault/capabilities.go b/vault/capabilities.go index 39a30bd3db..82d65558aa 100644 --- a/vault/capabilities.go +++ b/vault/capabilities.go @@ -3,12 +3,12 @@ package vault // Struct to identify user input errors. // This is helpful in responding the appropriate status codes to clients // from the HTTP endpoints. -type ErrUserInput struct { +type StatusBadRequest struct { Message string } // Implementing error interface -func (e *ErrUserInput) Error() string { +func (e *StatusBadRequest) Error() string { return e.Message } @@ -16,13 +16,13 @@ func (e *ErrUserInput) Error() string { // the token accessor an the given path func (c *Core) CapabilitiesAccessor(accessorID, path string) ([]string, error) { if path == "" { - return nil, &ErrUserInput{ + return nil, &StatusBadRequest{ Message: "missing path", } } if accessorID == "" { - return nil, &ErrUserInput{ + return nil, &StatusBadRequest{ Message: "missing accessor_id", } } @@ -38,13 +38,13 @@ func (c *Core) CapabilitiesAccessor(accessorID, path string) ([]string, error) { // Capabilities is used to fetch the capabilities of the given token on the given path func (c *Core) Capabilities(token, path string) ([]string, error) { if path == "" { - return nil, &ErrUserInput{ + return nil, &StatusBadRequest{ Message: "missing path", } } if token == "" { - return nil, &ErrUserInput{ + return nil, &StatusBadRequest{ Message: "missing token", } } @@ -54,7 +54,7 @@ func (c *Core) Capabilities(token, path string) ([]string, error) { return nil, err } if te == nil { - return nil, &ErrUserInput{ + return nil, &StatusBadRequest{ Message: "invalid token", } } diff --git a/vault/token_store.go b/vault/token_store.go index 39600b169f..66d1d6ecb8 100644 --- a/vault/token_store.go +++ b/vault/token_store.go @@ -606,7 +606,7 @@ func (ts *TokenStore) lookupByAccessorID(accessorID string) (string, error) { return "", fmt.Errorf("failed to read index using accessor ID: %s", err) } if entry == nil { - return "", &ErrUserInput{ + return "", &StatusBadRequest{ Message: "invalid accessor ID", } }