Documentation
¶
Index ¶
- Constants
- func ClassifyError(err error, statusCode int, graphqlErrors []GraphQLError) string
- func ExtractRetryAfter(resp *http.Response) string
- func IsRetryableStatusCode(statusCode int) bool
- func LogError(ctx context.Context, errorType string, err error, ...)
- func NewAuthenticationError(message string) diag.Diagnostic
- func NewGraphQLError(message string) diag.Diagnostic
- func NewHTTPError(statusCode int, body, url string) diag.Diagnostic
- func NewRateLimitError(retryAfter string) diag.Diagnostic
- func NewValidationError(summary, detail string) diag.Diagnostic
- func ShouldRetry(errorType string, attempt int, maxRetries int) bool
- type GraphQLError
- type GraphQLErrorLocation
- type HTTPError
Constants ¶
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 ¶
ExtractRetryAfter extracts retry-after header from HTTP response
func IsRetryableStatusCode ¶
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
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 ¶
GraphQLErrorLocation represents the location of a GraphQL error