-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patherrors.go
More file actions
40 lines (34 loc) · 923 Bytes
/
errors.go
File metadata and controls
40 lines (34 loc) · 923 Bytes
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
34
35
36
37
38
39
40
package vault
import (
"errors"
"fmt"
)
var (
ErrSecretNotFound = errors.New("secret not found")
ErrInvalidKey = errors.New("invalid secret key")
ErrNoAccess = errors.New("access denied")
ErrInvalidConfig = errors.New("invalid configuration")
ErrVaultNotFound = errors.New("vault not found")
ErrDecryptionFailed = errors.New("decryption failed")
ErrInvalidRecipient = errors.New("invalid recipient")
ErrPathNotSecure = errors.New("path is not secure")
)
type VaultPathError struct {
Path string
Err error
}
func (e *VaultPathError) Error() string {
if e.Path != "" {
return fmt.Sprintf("%s (%s): %v", ErrPathNotSecure, e.Path, e.Err)
}
return fmt.Sprintf("%v: %v", ErrPathNotSecure, e.Err)
}
func (e *VaultPathError) Unwrap() error {
return e.Err
}
func NewVaultPathError(path string) *VaultPathError {
return &VaultPathError{
Path: path,
Err: ErrPathNotSecure,
}
}