errors

package
v0.10.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package errors provides standardized error types for the Flight SQL server.

Index

Constants

View Source
const (
	CodeInvalidRequest     = "INVALID_REQUEST"
	CodeNotFound           = "NOT_FOUND"
	CodeAlreadyExists      = "ALREADY_EXISTS"
	CodeTransactionFailed  = "TRANSACTION_FAILED"
	CodeQueryFailed        = "QUERY_FAILED"
	CodeStatementFailed    = "STATEMENT_FAILED"
	CodeConnectionFailed   = "CONNECTION_FAILED"
	CodeMetadataFailed     = "METADATA_FAILED"
	CodeInternal           = "INTERNAL_ERROR"
	CodeUnavailable        = "UNAVAILABLE"
	CodeDeadlineExceeded   = "DEADLINE_EXCEEDED"
	CodeCanceled           = "CANCELED"
	CodeFailedPrecondition = "FAILED_PRECONDITION"
	CodeAborted            = "ABORTED"
	CodeResourceExhausted  = "RESOURCE_EXHAUSTED"
	CodeUnimplemented      = "UNIMPLEMENTED"
	CodeUnauthorized       = "UNAUTHORIZED"
	CodePermissionDenied   = "PERMISSION_DENIED"
)

Error codes matching gRPC/Flight SQL conventions

Variables

View Source
var (
	ErrInvalidQuery        = &FlightError{Code: CodeInvalidRequest, Message: "invalid query"}
	ErrTransactionNotFound = &FlightError{Code: CodeNotFound, Message: "transaction not found"}
	ErrStatementNotFound   = &FlightError{Code: CodeNotFound, Message: "prepared statement not found"}
	ErrTableNotFound       = &FlightError{Code: CodeNotFound, Message: "table not found"}
	ErrSchemaNotFound      = &FlightError{Code: CodeNotFound, Message: "schema not found"}
	ErrCatalogNotFound     = &FlightError{Code: CodeNotFound, Message: "catalog not found"}
	ErrInvalidTransaction  = &FlightError{Code: CodeInvalidRequest, Message: "invalid transaction"}
	ErrTransactionActive   = &FlightError{Code: CodeAlreadyExists, Message: "transaction already active"}
	ErrConnectionFailed    = &FlightError{Code: CodeUnavailable, Message: "database connection failed"}
	ErrQueryTimeout        = &FlightError{Code: CodeDeadlineExceeded, Message: "query execution timeout"}
	ErrResourceExhausted   = &FlightError{Code: CodeResourceExhausted, Message: "resource limit exceeded"}
	ErrNotImplemented      = &FlightError{Code: CodeUnimplemented, Message: "feature not implemented"}
)

Common errors

Functions

func GetCode

func GetCode(err error) string

GetCode extracts the error code from an error.

func GetMessage

func GetMessage(err error) string

GetMessage extracts the error message from an error.

func IsInternal

func IsInternal(err error) bool

IsInternal checks if an error is an internal error.

func IsInvalidRequest

func IsInvalidRequest(err error) bool

IsInvalidRequest checks if an error is an invalid request error.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound checks if an error is a not found error.

Types

type FlightError

type FlightError struct {
	Code    string                 `json:"code"`
	Message string                 `json:"message"`
	Details map[string]interface{} `json:"details,omitempty"`
	Cause   error                  `json:"-"`
}

FlightError represents a Flight SQL error with code, message, and optional details.

func New

func New(code, message string) *FlightError

New creates a new FlightError with the given code and message.

func Wrap

func Wrap(err error, code, message string) *FlightError

Wrap wraps an error with a FlightError.

func Wrapf

func Wrapf(err error, code, format string, args ...interface{}) *FlightError

Wrapf wraps an error with a formatted message.

func (*FlightError) Error

func (e *FlightError) Error() string

Error implements the error interface.

func (*FlightError) Is

func (e *FlightError) Is(target error) bool

Is implements error comparison.

func (*FlightError) Unwrap

func (e *FlightError) Unwrap() error

Unwrap returns the underlying error.

func (*FlightError) WithDetail

func (e *FlightError) WithDetail(key string, value interface{}) *FlightError

WithDetail adds a single detail to the error.

func (*FlightError) WithDetails

func (e *FlightError) WithDetails(details map[string]interface{}) *FlightError

WithDetails adds details to the error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL