errors

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorTypeNetwork    = "network"
	ErrorTypeGraphQL    = "graphql"
	ErrorTypeValidation = "validation"
	ErrorTypeRateLimit  = "rate_limit"
	ErrorTypeAuth       = "authentication"
	ErrorTypeBusiness   = "business_logic"
)

Error types for classification

Variables

This section is empty.

Functions

func ClassifyError

func ClassifyError(err error, statusCode int, graphqlErrors []GraphQLError) string

ClassifyError classifies an error based on its characteristics

func ExtractRetryAfter

func ExtractRetryAfter(resp *http.Response) string

ExtractRetryAfter extracts retry-after header from HTTP response

func IsRetryableStatusCode

func IsRetryableStatusCode(statusCode int) bool

IsRetryableStatusCode checks if an HTTP status code indicates a retryable error

func LogError

func LogError(ctx context.Context, errorType string, err error, additionalFields map[string]interface{})

LogError logs an error with appropriate context

func NewAuthenticationError

func NewAuthenticationError(message string) diag.Diagnostic

NewAuthenticationError creates a new authentication error diagnostic

func NewGraphQLError

func NewGraphQLError(message string) diag.Diagnostic

NewGraphQLError creates a new GraphQL error diagnostic

func NewHTTPError

func NewHTTPError(statusCode int, body, url string) diag.Diagnostic

NewHTTPError creates a new HTTP error diagnostic

func NewRateLimitError

func NewRateLimitError(retryAfter string) diag.Diagnostic

NewRateLimitError creates a new rate limit error diagnostic

func NewValidationError

func NewValidationError(summary, detail string) diag.Diagnostic

NewValidationError creates a new validation error diagnostic

func ShouldRetry

func ShouldRetry(errorType string, attempt int, maxRetries int) bool

ShouldRetry determines if an error should be retried

Types

type GraphQLError

type GraphQLError struct {
	Message    string                 `json:"message"`
	Locations  []GraphQLErrorLocation `json:"locations,omitempty"`
	Path       []string               `json:"path,omitempty"`
	Extensions map[string]interface{} `json:"extensions,omitempty"`
}

GraphQLError represents a GraphQL error

type GraphQLErrorLocation

type GraphQLErrorLocation struct {
	Line   int `json:"line"`
	Column int `json:"column"`
}

GraphQLErrorLocation represents the location of a GraphQL error

type HTTPError

type HTTPError struct {
	StatusCode int
	Body       string
	URL        string
}

HTTPError represents an HTTP error

Jump to

Keyboard shortcuts

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