Documentation
¶
Overview ¶
Package errors provides standardized error types for the Flight SQL server.
Index ¶
Constants ¶
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" CodeDeadlineExceeded = "DEADLINE_EXCEEDED" CodeCanceled = "CANCELED" CodeFailedPrecondition = "FAILED_PRECONDITION" CodeAborted = "ABORTED" CodeResourceExhausted = "RESOURCE_EXHAUSTED" CodeUnimplemented = "UNIMPLEMENTED" CodePermissionDenied = "PERMISSION_DENIED" )
Error codes matching gRPC/Flight SQL conventions
Variables ¶
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 GetMessage ¶
GetMessage extracts the error message from an error.
func IsInternal ¶
IsInternal checks if an error is an internal error.
func IsInvalidRequest ¶
IsInvalidRequest checks if an error is an invalid request error.
func IsNotFound ¶
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.