errors

package
v0.0.0-...-172bf2a Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: MIT Imports: 5 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ScimErrorInvalidFilter returns an 400 SCIM error with a detailed message.
	ScimErrorInvalidFilter = ScimError{
		ScimType: ScimTypeInvalidFilter,
		Detail:   "The specified filter syntax was invalid, or the specified attribute and filter comparison combination is not supported.",
		Status:   http.StatusBadRequest,
	}
	// ScimErrorTooMany returns an 400 SCIM error with a detailed message.
	ScimErrorTooMany = ScimError{
		ScimType: ScimTypeTooMany,
		Detail:   "The specified filter yields many more results than the server is willing to calculate or process.",
		Status:   http.StatusBadRequest,
	}
	// ScimErrorUniqueness returns an 409 SCIM error with a detailed message.
	ScimErrorUniqueness = ScimError{
		ScimType: ScimTypeUniqueness,
		Detail:   "One or more of the attribute values are already in use or are reserved.",
		Status:   http.StatusConflict,
	}
	// ScimErrorMutability returns an 400 SCIM error with a detailed message.
	ScimErrorMutability = ScimError{
		ScimType: ScimTypeMutability,
		Detail:   "The attempted modification is not compatible with the target attribute's mutability or current state.",
		Status:   http.StatusBadRequest,
	}
	// ScimErrorInvalidSyntax returns an 400 SCIM error with a detailed message.
	ScimErrorInvalidSyntax = ScimError{
		ScimType: ScimTypeInvalidSyntax,
		Detail:   "The request body message structure was invalid or did not conform to the request schema.",
		Status:   http.StatusBadRequest,
	}
	// ScimErrorInvalidPath returns an 400 SCIM error with a detailed message.
	ScimErrorInvalidPath = ScimError{
		ScimType: ScimTypeInvalidPath,
		Detail:   "The \"path\" attribute was invalid or malformed.",
		Status:   http.StatusBadRequest,
	}
	// ScimErrorNoTarget returns an 400 SCIM error with a detailed message.
	ScimErrorNoTarget = ScimError{
		ScimType: ScimTypeNoTarget,
		Detail:   "The specified path did not yield an attribute or attribute value that could be operated on.",
		Status:   http.StatusBadRequest,
	}
	// ScimErrorInvalidValue returns an 400 SCIM error with a detailed message.
	ScimErrorInvalidValue = ScimError{
		ScimType: ScimTypeInvalidValue,
		Detail:   "A required value was missing, or the value specified was not compatible with the operation or attribute type, or resource schema.",
		Status:   http.StatusBadRequest,
	}
	// ScimErrorInvalidVersion returns an 400 SCIM error with a detailed message.
	ScimErrorInvalidVersion = ScimError{
		ScimType: ScimTypeInvalidVersion,
		Detail:   "The specified SCIM protocol version is not supported.",
		Status:   http.StatusBadRequest,
	}
	// ScimErrorSensitive returns an 403 SCIM error with a detailed message.
	ScimErrorSensitive = ScimError{
		ScimType: ScimTypeSensitive,
		Detail:   "The specified request cannot be completed, due to the passing of sensitive information in a request URI.",
		Status:   http.StatusForbidden,
	}
	// ScimErrorInternal returns an 500 SCIM error without a message.
	ScimErrorInternal = ScimError{
		Status: http.StatusInternalServerError,
	}
)

Functions

This section is empty.

Types

type ScimError

type ScimError struct {
	// scimType is a SCIM detail error keyword.
	ScimType ScimType
	// detail is a detailed human-readable message.
	Detail string
	// status is the HTTP status code expressed as a JSON string. REQUIRED.
	Status int
}

ScimError is a SCIM error response to indicate operation success or failure.

func CheckScimError

func CheckScimError(err error, method string) ScimError

CheckScimError checks whether the error's status code is defined by SCIM for the given HTTP method.

func ScimErrorBadParams

func ScimErrorBadParams(invalidParams []string) ScimError

ScimErrorBadParams returns an 400 SCIM error with a detailed message based on the invalid parameters.

func ScimErrorBadRequest

func ScimErrorBadRequest(msg string) ScimError

ScimErrorBadRequest returns an 400 SCIM error with the given message.

func ScimErrorResourceNotFound

func ScimErrorResourceNotFound(id string) ScimError

ScimErrorResourceNotFound returns an 404 SCIM error with a detailed message based on the id.

func (ScimError) Error

func (e ScimError) Error() string

func (ScimError) MarshalJSON

func (e ScimError) MarshalJSON() ([]byte, error)

MarshalJSON converts the error struct to its corresponding json representation.

func (*ScimError) UnmarshalJSON

func (e *ScimError) UnmarshalJSON(data []byte) error

UnmarshalJSON converts the error json data to its corresponding struct representation.

type ScimType

type ScimType string

ScimType is A SCIM detail error keyword. Source: RFC7644.3.12 Table9.

const (
	// ScimTypeInvalidFilter indicates that the specified filter syntax was invalid or the specified attribute and
	// filter comparison combination is not supported.
	ScimTypeInvalidFilter ScimType = "invalidFilter"
	// ScimTypeTooMany indicates that the specified filter yields many more results than the server is willing to
	// calculate or process.
	ScimTypeTooMany ScimType = "tooMany"
	// ScimTypeUniqueness indicates that one or more of the attribute values are already in use or are reserved.
	ScimTypeUniqueness ScimType = "uniqueness"
	// ScimTypeMutability indicates that the attempted modification is not compatible with the target attribute's
	// mutability or current state.
	ScimTypeMutability ScimType = "mutability"
	// ScimTypeInvalidSyntax indicates that the request body message structure was invalid or did not conform to the
	// request schema.
	ScimTypeInvalidSyntax ScimType = "invalidSyntax"
	// ScimTypeInvalidPath indicates that the "path" attribute was invalid or malformed.
	ScimTypeInvalidPath ScimType = "invalidPath"
	// ScimTypeNoTarget indicates that the specified "path" did not yield an attribute or attribute value that could be
	// operated on.
	ScimTypeNoTarget ScimType = "noTarget"
	// ScimTypeInvalidValue indicates that a required value was missing or the value specified was not compatible with
	// the operation, attribute type or resource schema.
	ScimTypeInvalidValue ScimType = "invalidValue"
	// ScimTypeInvalidVersion indicates that the specified SCIM protocol version is not supported.
	ScimTypeInvalidVersion ScimType = "invalidVers"
	// ScimTypeSensitive indicates that the specified request cannot be completed, due to the passing of sensitive information in a request URI.
	ScimTypeSensitive ScimType = "sensitive"
)

Jump to

Keyboard shortcuts

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