{"modulePath":"github.com/go-openapi/errors","version":"v0.22.9","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package errors\n\nPackage errors provides an Error interface and several concrete types implementing this interface to manage API errors and JSON-schema validation errors.\n\nA middleware handler [ServeError](#ServeError)() is provided to serve the errors types it defines.\n\nIt is used throughout the various go-openapi toolkit libraries. ([https://github.com/go-openapi](https://github.com/go-openapi)).\n\n## Constants\n\n```go\nconst (\n\t// CompositeErrorCode remains 422 for backwards-compatibility\n\t// and to separate it from validation errors with cause.\n\tCompositeErrorCode = http.StatusUnprocessableEntity\n\n\t// InvalidTypeCode is used for any subclass of invalid types.\n\tInvalidTypeCode = maximumValidHTTPCode + iota\n\t// RequiredFailCode indicates a required field is missing.\n\tRequiredFailCode\n\tTooLongFailCode\n\tTooShortFailCode\n\tPatternFailCode\n\tEnumFailCode\n\tMultipleOfFailCode\n\tMaxFailCode\n\tMinFailCode\n\tUniqueFailCode\n\tMaxItemsFailCode\n\tMinItemsFailCode\n\tNoAdditionalItemsCode\n\tTooFewPropertiesCode\n\tTooManyPropertiesCode\n\tUnallowedPropertyCode\n\tFailedAllPatternPropsCode\n\tMultipleOfMustBePositiveCode\n\tReadOnlyFailCode\n)\n```\nAll code responses can be used to differentiate errors for different handling by the consuming program.\n\n## Variables\n\n```go\nvar DefaultHTTPCode = http.StatusUnprocessableEntity\n```\nDefaultHTTPCode is used when the error Code cannot be used as an HTTP code.\n\n## Functions\n\n```go\nfunc ServeError(rw http.ResponseWriter, r *http.Request, err error)\n```\nServeError implements the [http](/net/http) error handler interface.\n\n## Types\n\n```go\ntype APIVerificationFailed struct {\n\tSection              string   `json:\"section,omitempty\"`\n\tMissingSpecification []string `json:\"missingSpecification,omitempty\"`\n\tMissingRegistration  []string `json:\"missingRegistration,omitempty\"`\n}\n```\nAPIVerificationFailed is an error that contains all the missing info for a mismatched section between the api registrations and the api spec.\n\n```go\nfunc (v *APIVerificationFailed) Error() string\n```\nError implements the standard error interface.\n\n```go\ntype CompositeError struct {\n\tErrors []error\n\t// contains filtered or unexported fields\n}\n```\nCompositeError is an error that groups several errors together.\n\n```go\nfunc CompositeValidationError(errors ...error) *CompositeError\n```\nCompositeValidationError an error to wrap a bunch of other errors.\n\n```go\nfunc (c *CompositeError) Code() int32\n```\nCode returns the HTTP status code for this composite error.\n\n```go\nfunc (c *CompositeError) Error() string\n```\nError implements the standard error interface.\n\n```go\nfunc (c CompositeError) MarshalJSON() ([]byte, error)\n```\nMarshalJSON implements the JSON encoding interface.\n\n```go\nfunc (c *CompositeError) Unwrap() []error\n```\nUnwrap implements the [errors.Unwrap](/errors#Unwrap) interface.\n\n```go\nfunc (c *CompositeError) ValidateName(name string) *CompositeError\n```\nValidateName recursively sets the name for all validations or updates them for nested properties.\n\n```go\ntype Error interface {\n\terror\n\tCode() int32\n}\n```\nError represents a error interface all swagger framework errors implement.\n\n```go\nfunc MethodNotAllowed(requested string, allow []string) Error\n```\nMethodNotAllowed creates a new method not allowed error.\n\n```go\nfunc New(code int32, message string, args ...any) Error\n```\nNew creates a new API error with a code and a message.\n\n```go\nfunc NotFound(message string, args ...any) Error\n```\nNotFound creates a new not found error.\n\n```go\nfunc NotImplemented(message string) Error\n```\nNotImplemented creates a new not implemented error.\n\n```go\nfunc Unauthenticated(scheme string) Error\n```\nUnauthenticated returns an unauthenticated error.\n\n```go\ntype MethodNotAllowedError struct {\n\tAllowed []string\n\t// contains filtered or unexported fields\n}\n```\nMethodNotAllowedError represents an error for when the path matches but the method doesn't.\n\n```go\nfunc (m *MethodNotAllowedError) Code() int32\n```\nCode returns 405 (Method Not Allowed) as the HTTP status code.\n\n```go\nfunc (m *MethodNotAllowedError) Error() string\n```\nError implements the standard error interface.\n\n```go\nfunc (m MethodNotAllowedError) MarshalJSON() ([]byte, error)\n```\nMarshalJSON implements the JSON encoding interface.\n\n```go\ntype ParseError struct {\n\tName   string\n\tIn     string\n\tValue  string\n\tReason error\n\t// contains filtered or unexported fields\n}\n```\nParseError represents a parsing error.\n\n```go\nfunc NewParseError(name, in, value string, reason error) *ParseError\n```\nNewParseError creates a new parse error.\n\n```go\nfunc (e *ParseError) Code() int32\n```\nCode returns 400 (Bad Request) as the HTTP status code for parsing errors.\n\n```go\nfunc (e *ParseError) Error() string\n```\nError implements the standard error interface.\n\n```go\nfunc (e ParseError) MarshalJSON() ([]byte, error)\n```\nMarshalJSON implements the JSON encoding interface.\n\n```go\ntype Validation struct {\n\tName  string\n\tIn    string\n\tValue any\n\n\tValues []any\n\t// contains filtered or unexported fields\n}\n```\nValidation represents a failure of a precondition.\n\n```go\nfunc AdditionalItemsNotAllowed(name, in string) *Validation\n```\nAdditionalItemsNotAllowed an error for invalid additional items.\n\n```go\nfunc DuplicateItems(name, in string) *Validation\n```\nDuplicateItems error for when an array contains duplicates.\n\n```go\nfunc EnumFail(name, in string, value any, values []any) *Validation\n```\nEnumFail error for when an enum validation fails.\n\n```go\nfunc ExceedsMaximum(name, in string, maximum float64, exclusive bool, value any) *Validation\n```\nExceedsMaximum error for when maximum validation fails.\n\n```go\nfunc ExceedsMaximumInt(name, in string, maximum int64, exclusive bool, value any) *Validation\n```\nExceedsMaximumInt error for when maximum validation fails.\n\n```go\nfunc ExceedsMaximumUint(name, in string, maximum uint64, exclusive bool, value any) *Validation\n```\nExceedsMaximumUint error for when maximum validation fails.\n\n```go\nfunc ExceedsMinimum(name, in string, minimum float64, exclusive bool, value any) *Validation\n```\nExceedsMinimum error for when minimum validation fails.\n\n```go\nfunc ExceedsMinimumInt(name, in string, minimum int64, exclusive bool, value any) *Validation\n```\nExceedsMinimumInt error for when minimum validation fails.\n\n```go\nfunc ExceedsMinimumUint(name, in string, minimum uint64, exclusive bool, value any) *Validation\n```\nExceedsMinimumUint error for when minimum validation fails.\n\n```go\nfunc FailedAllPatternProperties(name, in, key string) *Validation\n```\nFailedAllPatternProperties an error for when the property doesn't match a pattern.\n\n```go\nfunc FailedPattern(name, in, pattern string, value any) *Validation\n```\nFailedPattern error for when a string fails a regex pattern match the pattern that is returned is the ECMA syntax version of the pattern not the golang version.\n\n```go\nfunc InvalidCollectionFormat(name, in, format string) *Validation\n```\nInvalidCollectionFormat another flavor of invalid type error.\n\n```go\nfunc InvalidContentType(value string, allowed []string) *Validation\n```\nInvalidContentType error for an invalid content type.\n\n```go\nfunc InvalidResponseFormat(value string, allowed []string) *Validation\n```\nInvalidResponseFormat error for an unacceptable response format request.\n\n```go\nfunc InvalidType(name, in, typeName string, value any) *Validation\n```\nInvalidType creates an error for when the type is invalid.\n\n```go\nfunc InvalidTypeName(typeName string) *Validation\n```\nInvalidTypeName an error for when the type is invalid.\n\n```go\nfunc MultipleOfMustBePositive(name, in string, factor any) *Validation\n```\nMultipleOfMustBePositive error for when a multipleOf factor is negative.\n\n```go\nfunc NotMultipleOf(name, in string, multiple, value any) *Validation\n```\nNotMultipleOf error for when multiple of validation fails.\n\n```go\nfunc PropertyNotAllowed(name, in, key string) *Validation\n```\nPropertyNotAllowed an error for when the property doesn't match a pattern.\n\n```go\nfunc ReadOnly(name, in string, value any) *Validation\n```\nReadOnly error for when a value is present in request.\n\n```go\nfunc Required(name, in string, value any) *Validation\n```\nRequired error for when a value is missing.\n\n```go\nfunc TooFewItems(name, in string, minimum int64, value any) *Validation\n```\nTooFewItems error for when an array contains too few items.\n\n```go\nfunc TooFewProperties(name, in string, n int64) *Validation\n```\nTooFewProperties an error for an object with too few properties.\n\n```go\nfunc TooLong(name, in string, maximum int64, value any) *Validation\n```\nTooLong error for when a string is too long.\n\n```go\nfunc TooManyItems(name, in string, maximum int64, value any) *Validation\n```\nTooManyItems error for when an array contains too many items.\n\n```go\nfunc TooManyProperties(name, in string, n int64) *Validation\n```\nTooManyProperties an error for an object with too many properties.\n\n```go\nfunc TooShort(name, in string, minimum int64, value any) *Validation\n```\nTooShort error for when a string is too short.\n\n```go\nfunc (e *Validation) Code() int32\n```\nCode returns the HTTP status code for this validation error. Returns 422 (Unprocessable Entity) by default.\n\n```go\nfunc (e *Validation) Error() string\n```\nError implements the standard error interface.\n\n```go\nfunc (e Validation) MarshalJSON() ([]byte, error)\n```\nMarshalJSON implements the JSON encoding interface.\n\n```go\nfunc (e *Validation) ValidateName(name string) *Validation\n```\nValidateName sets the name for a validation or updates it for a nested property.\n\n","path":"github.com/go-openapi/errors","name":"errors","synopsis":"Package errors provides an Error interface and several concrete types implementing this interface to manage API errors and JSON-schema validation errors.","isRedistributable":true}
