errors

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoAgentStateRow = &APIError{
	Type:    ErrorTypeConflict,
	Code:    "no_pending_agent_reload",
	Message: "workspace has no pending credentials to reload",
}

ErrNoAgentStateRow is returned by MarkAgentReloaded when the workspace_agent_state row does not exist for the given workspace. Both database.go (returns it) and handler code (checks via errors.Is) import this shared package — neither imports the other.

It is a *APIError (not a plain sentinel) so the centralized error handler (respondWithError) can map it to HTTP 409 Conflict automatically via StatusCode(). Callers can still use errors.Is for backwards compat and errors.As for the new typed-error path.

Functions

func IsWorkspaceNotFoundError

func IsWorkspaceNotFoundError(err error) bool

IsWorkspaceNotFoundError checks if the error is a WorkspaceNotFoundError

Types

type APIError

type APIError struct {
	Type    ErrorType              `json:"-"`
	Code    string                 `json:"code"`
	Message string                 `json:"message"`
	Details map[string]interface{} `json:"details,omitempty"`
	Err     error                  `json:"-"`
}

APIError represents an API error

func NewAuthenticationError

func NewAuthenticationError(message string, err error) *APIError

NewAuthenticationError creates a new authentication error

func NewBadRequestError

func NewBadRequestError(message string, err error) *APIError

NewBadRequestError creates a new bad request error

func NewConflictError

func NewConflictError(resourceType, resourceID string, err error) *APIError

NewConflictError creates a new conflict error

func NewForbiddenError

func NewForbiddenError(message string, err error) *APIError

NewForbiddenError creates a new forbidden error

func NewInternalError

func NewInternalError(message string, err error) *APIError

NewInternalError creates a new internal server error

func NewNotFoundError

func NewNotFoundError(resourceType, resourceID string, err error) *APIError

NewNotFoundError creates a new not found error

func NewNotImplementedError

func NewNotImplementedError(code string, message string, err error) *APIError

NewNotImplementedError creates a new not implemented error

func NewRateLimitError

func NewRateLimitError(message string, limit int, reset int64, err error) *APIError

NewRateLimitError creates a new rate limit error

func NewValidationError

func NewValidationError(message string, details map[string]interface{}, err error) *APIError

NewValidationError creates a new validation error

func (*APIError) Error

func (e *APIError) Error() string

Error implements the error interface

func (*APIError) StatusCode

func (e *APIError) StatusCode() int

StatusCode returns the HTTP status code for the error

func (*APIError) Unwrap

func (e *APIError) Unwrap() error

Unwrap returns the wrapped error

type ErrorType

type ErrorType string

ErrorType defines the type of error

const (
	// ErrorTypeValidation represents validation errors
	ErrorTypeValidation ErrorType = "validation_error"

	// ErrorTypeAuth represents authentication errors
	ErrorTypeAuth ErrorType = "auth_error"

	// ErrorTypeNotFound represents resource not found errors
	ErrorTypeNotFound ErrorType = "not_found"

	// ErrorTypeForbidden represents permission denied errors
	ErrorTypeForbidden ErrorType = "forbidden"

	// ErrorTypeConflict represents resource conflict errors
	ErrorTypeConflict ErrorType = "conflict"

	// ErrorTypeRateLimit represents rate limiting errors
	ErrorTypeRateLimit ErrorType = "rate_limited"

	// ErrorTypeInternal represents internal server errors
	ErrorTypeInternal ErrorType = "internal_error"

	// ErrorTypeBadRequest represents bad request errors
	ErrorTypeBadRequest ErrorType = "bad_request"
)

Jump to

Keyboard shortcuts

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