Documentation
¶
Overview ¶
Package errors contains API specific error implementation. The errors are related with specific neuron-core classes.
Index ¶
- Variables
- func ErrAccountAlreadyExists() *jsonapi.Error
- func ErrAccountDisabled() *jsonapi.Error
- func ErrBadRequest() *jsonapi.Error
- func ErrEndpointForbidden() *jsonapi.Error
- func ErrForbidden() *jsonapi.Error
- func ErrHashMismatch() *jsonapi.Error
- func ErrHeadersNotSupported() *jsonapi.Error
- func ErrIDConflict() *jsonapi.Error
- func ErrInputOutOfRange() *jsonapi.Error
- func ErrInsufficientAccountPermissions() *jsonapi.Error
- func ErrInternalError() *jsonapi.Error
- func ErrInvalidAuthenticationInfo() *jsonapi.Error
- func ErrInvalidAuthorizationHeader() *jsonapi.Error
- func ErrInvalidCredentials() *jsonapi.Error
- func ErrInvalidHeaderValue() *jsonapi.Error
- func ErrInvalidInput() *jsonapi.Error
- func ErrInvalidJSONDocument() *jsonapi.Error
- func ErrInvalidJSONFieldValue() *jsonapi.Error
- func ErrInvalidQueryParameter() *jsonapi.Error
- func ErrInvalidResourceName() *jsonapi.Error
- func ErrInvalidURI() *jsonapi.Error
- func ErrLanguageHeaderNotAcceptable() *jsonapi.Error
- func ErrLanguageNotAcceptable() *jsonapi.Error
- func ErrMetadataTooLarge() *jsonapi.Error
- func ErrMethodNotAllowed() *jsonapi.Error
- func ErrMissingRequiredHeader() *jsonapi.Error
- func ErrMissingRequiredModelField() *jsonapi.Error
- func ErrMissingRequiredQueryParameter() *jsonapi.Error
- func ErrNotAcceptable() *jsonapi.Error
- func ErrOperationTimedOut() *jsonapi.Error
- func ErrQueryParameterValueOutOfRange() *jsonapi.Error
- func ErrRequestBodyTooLarge() *jsonapi.Error
- func ErrResourceAlreadyExists() *jsonapi.Error
- func ErrResourceNotFound() *jsonapi.Error
- func ErrServiceUnavailable() *jsonapi.Error
- func ErrTooManyOperationsPerAccount() *jsonapi.Error
- func ErrTypeConflict() *jsonapi.Error
- func ErrUnsupportedField() *jsonapi.Error
- func ErrUnsupportedFilterOperator() *jsonapi.Error
- func ErrUnsupportedHeader() *jsonapi.Error
- func ErrUnsupportedQueryParameter() *jsonapi.Error
- func ErrWarningNotification() *jsonapi.Error
- func MapError(err error) []*jsonapi.Error
- type ClassMapper
- type Creator
- type MultiError
Constants ¶
This section is empty.
Variables ¶
var DefaultClassMapper = &ClassMapper{ Majors: map[errors.Major]Creator{ class.MjrCommon: ErrInternalError, class.MjrConfig: ErrInternalError, class.MjrEncoding: ErrInvalidInput, class.MjrLanguage: ErrLanguageNotAcceptable, class.MjrInternal: ErrInternalError, class.MjrQuery: ErrInvalidQueryParameter, class.MjrRepository: ErrServiceUnavailable, class.MjrModel: ErrInternalError, }, Minors: map[errors.Minor]Creator{ class.MnrEncodingUnmarshal: ErrInvalidInput, class.MnrEncodingMarshal: ErrInternalError, class.MnrQueryFieldset: ErrInvalidQueryParameter, class.MnrQuerySelectedFields: ErrInternalError, class.MnrQueryPagination: ErrInvalidQueryParameter, class.MnrQueryFilter: ErrInvalidQueryParameter, class.MnrQuerySorts: ErrInvalidQueryParameter, class.MnrQueryViolation: ErrInvalidJSONFieldValue, class.MnrQueryInclude: ErrInvalidQueryParameter, class.MnrQueryValue: ErrInvalidInput, class.MnrQueryTransaction: ErrInternalError, class.MnrRepositoryNotImplements: ErrInternalError, class.MnrRepositoryConnection: ErrServiceUnavailable, class.MnrRepositoryReplica: ErrInternalError, }, Class: map[errors.Class]Creator{ class.EncodingUnmarshalCollection: ErrTypeConflict, class.EncodingUnmarshalUnknownField: ErrInvalidResourceName, class.EncodingUnmarshalInvalidID: ErrInvalidJSONFieldValue, class.EncodingUnmarshalInvalidFormat: ErrInvalidJSONDocument, class.EncodingUnmarshalInvalidTime: ErrInvalidJSONFieldValue, class.EncodingUnmarshalInvalidType: ErrInvalidJSONFieldValue, class.EncodingUnmarshalValueOutOfRange: ErrInputOutOfRange, class.EncodingUnmarshalNoData: ErrInvalidInput, class.QueryFieldsetDuplicate: ErrInvalidQueryParameter, class.QueryFieldsetTooBig: ErrInvalidQueryParameter, class.QueryFieldsetUnknownField: ErrInvalidResourceName, class.QueryFieldsetInvalid: ErrInternalError, class.QueryFilterUnknownCollection: ErrInvalidResourceName, class.QueryFilterUnknownField: ErrInvalidResourceName, class.QueryFilterUnknownOperator: ErrInvalidQueryParameter, class.QueryFilterMissingRequired: ErrMissingRequiredQueryParameter, class.QueryFilterUnsupportedField: ErrUnsupportedField, class.QueryFilterUnsupportedOperator: ErrUnsupportedFilterOperator, class.QueryFilterLanguage: ErrLanguageNotAcceptable, class.QueryFilterInvalidField: ErrInvalidQueryParameter, class.QueryFilterInvalidFormat: ErrInvalidQueryParameter, class.QuerySortField: ErrInvalidResourceName, class.QuerySortFormat: ErrInvalidQueryParameter, class.QuerySortRelatedFields: ErrUnsupportedQueryParameter, class.QuerySortTooManyFields: ErrInvalidQueryParameter, class.QueryPaginationAlreadySet: ErrInternalError, class.QueryViolationCheck: ErrInvalidJSONFieldValue, class.QueryViolationUnique: ErrResourceAlreadyExists, class.QueryViolationNotNull: ErrInvalidJSONFieldValue, class.QueryValueValidation: ErrInvalidJSONFieldValue, class.QueryValueUnaddressable: ErrInternalError, class.QueryValueType: ErrInternalError, class.QueryValuePrimary: ErrInvalidJSONFieldValue, class.QueryValueMissingRequired: ErrInvalidInput, class.QueryValueNoResult: ErrResourceNotFound, class.QueryIncludeTooMany: ErrInvalidQueryParameter, class.RepositoryNotFound: ErrInternalError, class.RepositoryAuthPrivileges: ErrInternalError, class.CommonParseBrackets: ErrInvalidQueryParameter, class.ModelSchemaNotFound: ErrInternalError, }, }
DefaultClassMapper is the default error classification mapper.
Functions ¶
func ErrAccountAlreadyExists ¶
ErrAccountAlreadyExists creating account failed - user already exists.
func ErrAccountDisabled ¶
ErrAccountDisabled provided account is disabled.
func ErrBadRequest ¶
ErrBadRequest is the API error thrown on bad request
func ErrEndpointForbidden ¶
ErrEndpointForbidden forbidden access above given API endpoint.
func ErrForbidden ¶
ErrForbidden server understood the request but refuses to authorize it.
func ErrHashMismatch ¶
ErrHashMismatch returns when the hash value specified in the request didn't match the one stored/computed by the server.
func ErrHeadersNotSupported ¶
ErrHeadersNotSupported errors thrown when the provided HTTP headers are not supported by the server
func ErrIDConflict ¶
ErrIDConflict defines an error when the primary field value doesn't match endpoint's defined id.
func ErrInputOutOfRange ¶
ErrInputOutOfRange one of the request inputs were out of range.
func ErrInsufficientAccountPermissions ¶
ErrInsufficientAccountPermissions provided account has insufficient permissions for given request.
func ErrInternalError ¶
ErrInternalError server encountered internal error.
func ErrInvalidAuthenticationInfo ¶
ErrInvalidAuthenticationInfo defines the error when the authentication fails.
func ErrInvalidAuthorizationHeader ¶
ErrInvalidAuthorizationHeader server failed to authenticate the request due to invalid authorization header.
func ErrInvalidCredentials ¶
ErrInvalidCredentials provided invalid account credentials - access denied.
func ErrInvalidHeaderValue ¶
ErrInvalidHeaderValue responsed when some HTTP header was not in a valid format.
func ErrInvalidInput ¶
ErrInvalidInput returned when provided request input is not valid.
func ErrInvalidJSONDocument ¶
ErrInvalidJSONDocument error returned when the specified JSON structure is not syntetically valid.
func ErrInvalidJSONFieldValue ¶
ErrInvalidJSONFieldValue error returned when one or more of the specified JSON fields was not in a correct format.
func ErrInvalidQueryParameter ¶
ErrInvalidQueryParameter one of the query parameters has invalid value or format.
func ErrInvalidResourceName ¶
ErrInvalidResourceName defines an error when the specified resource name is not valid.
func ErrInvalidURI ¶
ErrInvalidURI error returned when the URI is not recognized by the server.
func ErrLanguageHeaderNotAcceptable ¶
ErrLanguageHeaderNotAcceptable provided request headers contains not supported language.
func ErrLanguageNotAcceptable ¶
ErrLanguageNotAcceptable languages provided in the request are not supported.
func ErrMetadataTooLarge ¶
ErrMetadataTooLarge the size of the specified metadata exceeds the limits.
func ErrMethodNotAllowed ¶
ErrMethodNotAllowed given method is not allowed for the specified URI
func ErrMissingRequiredHeader ¶
ErrMissingRequiredHeader one of the required HTTP headers were not specified in the request.
func ErrMissingRequiredModelField ¶
ErrMissingRequiredModelField one of the required model fields were not specified in the request body
func ErrMissingRequiredQueryParameter ¶
ErrMissingRequiredQueryParameter returns when one or more of the query parameter is missing for the request.
func ErrNotAcceptable ¶
ErrNotAcceptable one of the header contains values that are not possible to get the response by the server.
func ErrOperationTimedOut ¶
ErrOperationTimedOut the operation could not be completed within the permitted time.
func ErrQueryParameterValueOutOfRange ¶
ErrQueryParameterValueOutOfRange one of the specified query parameters in the request URI is outside the permissible range.
func ErrRequestBodyTooLarge ¶
ErrRequestBodyTooLarge the size of the request body exceeds the maximum permitted size.
func ErrResourceAlreadyExists ¶
ErrResourceAlreadyExists the specified resource already exists.
func ErrResourceNotFound ¶
ErrResourceNotFound provided resource doesn't exists.
func ErrServiceUnavailable ¶
ErrServiceUnavailable the server is currently unable to receive requests.
func ErrTooManyOperationsPerAccount ¶
ErrTooManyOperationsPerAccount too many requests for given account.
func ErrTypeConflict ¶
ErrTypeConflict defines an error when the data 'type' doesn't match endpoint's defined 'type'.
func ErrUnsupportedField ¶
ErrUnsupportedField one of the fields specified in the request is not supported.
func ErrUnsupportedFilterOperator ¶
ErrUnsupportedFilterOperator one of the filter operators is not supported.
func ErrUnsupportedHeader ¶
ErrUnsupportedHeader one of the HTTP headers specified in the request is not supported.
func ErrUnsupportedQueryParameter ¶
ErrUnsupportedQueryParameter one of the query parameters in the request URI is not supported.
func ErrWarningNotification ¶
ErrWarningNotification warns on response with some value.
Types ¶
type ClassMapper ¶
type ClassMapper struct { Majors map[errors.Major]Creator Minors map[errors.Minor]Creator Class map[errors.Class]Creator }
ClassMapper is the neuron errors classification mapper. It creates the 'Error' from the provided error.
func (*ClassMapper) Errors ¶
func (c *ClassMapper) Errors(err error) []*jsonapi.Error
Errors gets the slice of 'Error' from the provided 'err' error. The mapping is based on the 'most specific classification first' method. If the error is 'errors.ClassError' the function gets it's class. The function checks classification occurrence based on the priority:
- Class
- Minor
- Major
If no mapping is provided for given classification - an internal error is returned.
type MultiError ¶
MultiError is the multiple Error wrapper.
func (MultiError) Status ¶
func (m MultiError) Status() int
Status gets the most significant api error status.