featurebase/dax/errors.go
Travis Turner a9b3fd2c4d Database isolation: Balancer (#2407)
* Database isolation: Balancer

Remove naive Balancer

remove debugging lines

Thread dax.Transaction through Controller

Change role to roleType

Swap out Balancer interface with new one

Standardize InvalidTransaction error

Add some interface comments

* Remove type.Worker; replace with type.Address

* Remove database validate from Queryer

This is already being handled in the `CreateTable()` method. Prior
to doing that validation, we were getting a panic, but that's no longer
the case.

* Remove dax.TableQualifier; replace with dax.QualifiedDatabaseID

* Update IDK test to create database

(cherry picked from commit d971cfc269)
2023-01-19 22:10:08 +00:00

106 lines
2.6 KiB
Go

package dax
import (
"fmt"
"github.com/featurebasedb/featurebase/v3/errors"
)
const (
ErrDatabaseIDExists errors.Code = "DatabaseIDExists"
ErrDatabaseIDDoesNotExist errors.Code = "DatabaseIDDoesNotExist"
ErrTableIDExists errors.Code = "TableIDExists"
ErrTableKeyExists errors.Code = "TableKeyExists"
ErrTableNameExists errors.Code = "TableNameExists"
ErrTableIDDoesNotExist errors.Code = "TableIDDoesNotExist"
ErrTableKeyDoesNotExist errors.Code = "TableKeyDoesNotExist"
ErrTableNameDoesNotExist errors.Code = "TableNameDoesNotExist"
ErrFieldExists errors.Code = "FieldExists"
ErrFieldDoesNotExist errors.Code = "FieldDoesNotExist"
ErrInvalidTransaction errors.Code = "InvalidTransaction"
ErrUnimplemented errors.Code = "Unimplemented"
)
// The following are helper functions for constructing coded errors containing
// relevant information about the specific error.
func NewErrDatabaseIDExists(qdbid QualifiedDatabaseID) error {
return errors.New(
ErrDatabaseIDExists,
fmt.Sprintf("database ID '%s' already exists", qdbid),
)
}
func NewErrDatabaseIDDoesNotExist(qdbid QualifiedDatabaseID) error {
return errors.New(
ErrDatabaseIDDoesNotExist,
fmt.Sprintf("database ID '%s' does not exist", qdbid),
)
}
func NewErrTableIDDoesNotExist(qtid QualifiedTableID) error {
return errors.New(
ErrTableIDDoesNotExist,
fmt.Sprintf("table ID '%s' does not exist", qtid),
)
}
func NewErrTableKeyDoesNotExist(tkey TableKey) error {
return errors.New(
ErrTableKeyDoesNotExist,
fmt.Sprintf("table key '%s' does not exist", tkey),
)
}
func NewErrTableNameDoesNotExist(tableName TableName) error {
return errors.New(
ErrTableNameDoesNotExist,
fmt.Sprintf("table name '%s' does not exist", tableName),
)
}
func NewErrTableIDExists(qtid QualifiedTableID) error {
return errors.New(
ErrTableIDExists,
fmt.Sprintf("table ID '%s' already exists", qtid),
)
}
func NewErrTableKeyExists(tkey TableKey) error {
return errors.New(
ErrTableKeyExists,
fmt.Sprintf("table key '%s' already exists", tkey),
)
}
func NewErrTableNameExists(tableName TableName) error {
return errors.New(
ErrTableNameExists,
fmt.Sprintf("table name '%s' already exists", tableName),
)
}
func NewErrFieldDoesNotExist(fieldName FieldName) error {
return errors.New(
ErrFieldDoesNotExist,
fmt.Sprintf("field '%s' does not exist", fieldName),
)
}
func NewErrFieldExists(fieldName FieldName) error {
return errors.New(
ErrFieldExists,
fmt.Sprintf("field '%s' already exists", fieldName),
)
}
func NewErrInvalidTransaction() error {
return errors.New(
ErrInvalidTransaction,
"tx is not a *boltdb.Tx",
)
}