1package influxdb 2 3import ( 4 "errors" 5 "fmt" 6 "strings" 7) 8 9// ErrFieldTypeConflict is returned when a new field already exists with a 10// different type. 11var ErrFieldTypeConflict = errors.New("field type conflict") 12 13// ErrDatabaseNotFound indicates that a database operation failed on the 14// specified database because the specified database does not exist. 15func ErrDatabaseNotFound(name string) error { return fmt.Errorf("database not found: %s", name) } 16 17// ErrRetentionPolicyNotFound indicates that the named retention policy could 18// not be found in the database. 19func ErrRetentionPolicyNotFound(name string) error { 20 return fmt.Errorf("retention policy not found: %s", name) 21} 22 23// IsAuthorizationError indicates whether an error is due to an authorization failure 24func IsAuthorizationError(err error) bool { 25 e, ok := err.(interface { 26 AuthorizationFailed() bool 27 }) 28 return ok && e.AuthorizationFailed() 29} 30 31// IsClientError indicates whether an error is a known client error. 32func IsClientError(err error) bool { 33 if err == nil { 34 return false 35 } 36 37 if strings.HasPrefix(err.Error(), ErrFieldTypeConflict.Error()) { 38 return true 39 } 40 41 return false 42} 43