mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 19:17:58 +00:00
VAULT-24798: audit - improve error messages (#26312)
* audit: remove 'op' from error messages and do some clean up * Allow early error checking to be concerned with vault/Core vs. audit
This commit is contained in:
34
audit/errors.go
Normal file
34
audit/errors.go
Normal file
@@ -0,0 +1,34 @@
|
||||
// Copyright (c) HashiCorp, Inc.
|
||||
// SPDX-License-Identifier: BUSL-1.1
|
||||
|
||||
package audit
|
||||
|
||||
import "errors"
|
||||
|
||||
var (
|
||||
// ErrInternal should be used to represent an unexpected error that occurred
|
||||
// within the audit system.
|
||||
ErrInternal = errors.New("audit system internal error")
|
||||
|
||||
// ErrInvalidParameter should be used to represent an error in which the
|
||||
// internal audit system is receiving invalid parameters from other parts of
|
||||
// Vault which should have already been validated.
|
||||
ErrInvalidParameter = errors.New("invalid internal parameter")
|
||||
|
||||
// ErrExternalOptions should be used to represent an error related to
|
||||
// invalid configuration provided to Vault (i.e. by the Vault Operator).
|
||||
ErrExternalOptions = errors.New("invalid configuration")
|
||||
)
|
||||
|
||||
// ConvertToExternalError handles converting an error that was generated in Vault
|
||||
// and should appear as-is in the server logs, to an error that can be returned to
|
||||
// calling clients (via the API/CLI).
|
||||
func ConvertToExternalError(err error) error {
|
||||
// If the error is an internal error, the contents will have been logged, and
|
||||
// we should probably shield the caller from the details.
|
||||
if errors.Is(err, ErrInternal) {
|
||||
return ErrInternal
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
Reference in New Issue
Block a user