openapi-nexus 0.2.2

OpenAPI 3.x multi-language code generator
Documentation
package runtime

import (
	"errors"
	"fmt"
)

// APIError represents a non-2xx HTTP response from the API.
//
// Callers can type-assert via `errors.As` to inspect StatusCode and the raw
// response body.
type APIError struct {
	StatusCode int
	Status     string
	Body       []byte
}

func (e *APIError) Error() string {
	return fmt.Sprintf("api error: %s", e.Status)
}

// IsAPIError reports whether err is (or wraps) an *APIError.
func IsAPIError(err error) bool {
	var apiErr *APIError
	return errors.As(err, &apiErr)
}