errors.go

v1.0.0
Doc Versions Source
1
package bitwarden
2
3
import "fmt"
4
5
// APIError represents an error response from the bw serve API.
6
type APIError struct {
7
	StatusCode int
8
	Message    string
9
}
10
11
func (e *APIError) Error() string {
12
	if e.Message != "" {
13
		return fmt.Sprintf("bitwarden: HTTP %d: %s", e.StatusCode, e.Message)
14
	}
15
	return fmt.Sprintf("bitwarden: HTTP %d", e.StatusCode)
16
}
17
18
// VaultLockedError is returned when the vault is locked.
19
type VaultLockedError struct{}
20
21
func (e *VaultLockedError) Error() string {
22
	return "bitwarden: vault is locked"
23
}
24
25
// NotFoundError is returned when the requested object is not found.
26
type NotFoundError struct {
27
	Object string
28
	ID     string
29
}
30
31
func (e *NotFoundError) Error() string {
32
	return fmt.Sprintf("bitwarden: %s %q not found", e.Object, e.ID)
33
}
34

Source Files