package api

import "fmt"

// APIError represents a non-2xx HTTP response from the Forgejo API.
type APIError struct {
	StatusCode int
	Body       string
	Message    string
}

func (e *APIError) Error() string {
	if e.Body != "" {
		return fmt.Sprintf("API request failed with status %d: %s", e.StatusCode, e.Body)
	}
	return fmt.Sprintf("API request failed with status %d: %s", e.StatusCode, e.Message)
}
