Documentation
¶
Index ¶
- Variables
- func IsWorkspaceNotFoundError(err error) bool
- type APIError
- func NewAuthenticationError(message string, err error) *APIError
- func NewBadRequestError(message string, err error) *APIError
- func NewConflictError(resourceType, resourceID string, err error) *APIError
- func NewForbiddenError(message string, err error) *APIError
- func NewInternalError(message string, err error) *APIError
- func NewNotFoundError(resourceType, resourceID string, err error) *APIError
- func NewNotImplementedError(code string, message string, err error) *APIError
- func NewRateLimitError(message string, limit int, reset int64, err error) *APIError
- func NewValidationError(message string, details map[string]interface{}, err error) *APIError
- type ErrorType
Constants ¶
This section is empty.
Variables ¶
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 ¶
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 ¶
NewAuthenticationError creates a new authentication error
func NewBadRequestError ¶
NewBadRequestError creates a new bad request error
func NewConflictError ¶
NewConflictError creates a new conflict error
func NewForbiddenError ¶
NewForbiddenError creates a new forbidden error
func NewInternalError ¶
NewInternalError creates a new internal server error
func NewNotFoundError ¶
NewNotFoundError creates a new not found error
func NewNotImplementedError ¶
NewNotImplementedError creates a new not implemented error
func NewRateLimitError ¶
NewRateLimitError creates a new rate limit error
func NewValidationError ¶
NewValidationError creates a new validation error
func (*APIError) StatusCode ¶
StatusCode returns the HTTP status code for the 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" )