fn err_code(&self) -> ErrCode {
        use Code::*;

        match self {
            // index related errors
            CreateIndex => ErrCode::invalid("index_creation_failed", StatusCode::BAD_REQUEST),
            IndexAlreadyExists => ErrCode::invalid("index_already_exists", StatusCode::BAD_REQUEST),
            IndexNotFound => ErrCode::invalid("index_not_found", StatusCode::NOT_FOUND), InvalidIndexUid => ErrCode::invalid("invalid_index_uid", StatusCode::BAD_REQUEST),
            OpenIndex => ErrCode::internal("index_not_accessible", StatusCode::INTERNAL_SERVER_ERROR),

            // invalid state error
            InvalidState => ErrCode::internal("invalid_state", StatusCode::INTERNAL_SERVER_ERROR),
            MissingPrimaryKey => ErrCode::internal("missing_primary_key", StatusCode::INTERNAL_SERVER_ERROR),
            PrimaryKeyAlreadyPresent => ErrCode::internal("primary_key_already_present", StatusCode::INTERNAL_SERVER_ERROR),

            // invalid document
            MaxFieldsLimitExceeded => ErrCode::invalid("max_field_limit_exceeded", StatusCode::BAD_REQUEST),
            MissingDocumentId => ErrCode::invalid("missing_document_id", StatusCode::BAD_REQUEST),

            Facet => ErrCode::invalid("invalid_facet", StatusCode::BAD_REQUEST),
            Filter => ErrCode::invalid("invalid_filter", StatusCode::BAD_REQUEST),

            BadParameter => ErrCode::invalid("bad_parameter", StatusCode::BAD_REQUEST),
            BadRequest => ErrCode::invalid("bad_request", StatusCode::BAD_REQUEST),
            DocumentNotFound => ErrCode::internal("document_not_found", StatusCode::NOT_FOUND),
            Internal => ErrCode::internal("internal", StatusCode::INTERNAL_SERVER_ERROR),
            InvalidToken => ErrCode::authentication("invalid_token", StatusCode::FORBIDDEN),
            Maintenance =>  ErrCode::internal("maintenance", StatusCode::SERVICE_UNAVAILABLE),
            MissingAuthorizationHeader => ErrCode::authentication("missing_authorization_header", StatusCode::UNAUTHORIZED),
            NotFound => ErrCode::invalid("not_found", StatusCode::NOT_FOUND),
            PayloadTooLarge => ErrCode::invalid("payload_too_large", StatusCode::PAYLOAD_TOO_LARGE),
            RetrieveDocument => ErrCode::internal("unretrievable_document", StatusCode::BAD_REQUEST),
            SearchDocuments => ErrCode::internal("search_error", StatusCode::BAD_REQUEST),
            UnsupportedMediaType => ErrCode::invalid("unsupported_media_type", StatusCode::UNSUPPORTED_MEDIA_TYPE),
        }
    }
/// ascociate a `Code` variant to the actual ErrCode
ascociate a `Code` variant to the actual ErrCode
ascociate a ` Code ` variant to the actual ErrCode
fn err_code(&self) -> ErrCode {
        use Code::*;
        match self {
            // index related errors
            CreateIndex => ErrCode::invalid("index_creation_failed", StatusCode::BAD_REQUEST),
            IndexAlreadyExists => ErrCode::invalid("index_already_exists", StatusCode::BAD_REQUEST),
            IndexNotFound => ErrCode::invalid("index_not_found", StatusCode::NOT_FOUND), InvalidIndexUid => ErrCode::invalid("invalid_index_uid", StatusCode::BAD_REQUEST),
            OpenIndex => ErrCode::internal("index_not_accessible", StatusCode::INTERNAL_SERVER_ERROR),
            // invalid state error
            InvalidState => ErrCode::internal("invalid_state", StatusCode::INTERNAL_SERVER_ERROR),
            MissingPrimaryKey => ErrCode::internal("missing_primary_key", StatusCode::INTERNAL_SERVER_ERROR),
            PrimaryKeyAlreadyPresent => ErrCode::internal("primary_key_already_present", StatusCode::INTERNAL_SERVER_ERROR),
            // invalid document
            MaxFieldsLimitExceeded => ErrCode::invalid("max_field_limit_exceeded", StatusCode::BAD_REQUEST),
            MissingDocumentId => ErrCode::invalid("missing_document_id", StatusCode::BAD_REQUEST),
            Facet => ErrCode::invalid("invalid_facet", StatusCode::BAD_REQUEST),
            Filter => ErrCode::invalid("invalid_filter", StatusCode::BAD_REQUEST),
            BadParameter => ErrCode::invalid("bad_parameter", StatusCode::BAD_REQUEST),
            BadRequest => ErrCode::invalid("bad_request", StatusCode::BAD_REQUEST),
            DocumentNotFound => ErrCode::internal("document_not_found", StatusCode::NOT_FOUND),
            Internal => ErrCode::internal("internal", StatusCode::INTERNAL_SERVER_ERROR),
            InvalidToken => ErrCode::authentication("invalid_token", StatusCode::FORBIDDEN),
            Maintenance =>  ErrCode::internal("maintenance", StatusCode::SERVICE_UNAVAILABLE),
            MissingAuthorizationHeader => ErrCode::authentication("missing_authorization_header", StatusCode::UNAUTHORIZED),
            NotFound => ErrCode::invalid("not_found", StatusCode::NOT_FOUND),
            PayloadTooLarge => ErrCode::invalid("payload_too_large", StatusCode::PAYLOAD_TOO_LARGE),
            RetrieveDocument => ErrCode::internal("unretrievable_document", StatusCode::BAD_REQUEST),
            SearchDocuments => ErrCode::internal("search_error", StatusCode::BAD_REQUEST),
            UnsupportedMediaType => ErrCode::invalid("unsupported_media_type", StatusCode::UNSUPPORTED_MEDIA_TYPE),
        }
    }
fn err_code ( & self ) -> ErrCode { use Code :: * ; match self { // index related errors CreateIndex => ErrCode :: invalid ( " " , StatusCode :: BAD_REQUEST ) , IndexAlreadyExists => ErrCode :: invalid ( " " , StatusCode :: BAD_REQUEST ) , IndexNotFound => ErrCode :: invalid ( " " , StatusCode :: NOT_FOUND ) , InvalidIndexUid => ErrCode :: invalid ( " " , StatusCode :: BAD_REQUEST ) , OpenIndex => ErrCode :: internal ( " " , StatusCode :: INTERNAL_SERVER_ERROR ) , // invalid state error InvalidState => ErrCode :: internal ( " " , StatusCode :: INTERNAL_SERVER_ERROR ) , MissingPrimaryKey => ErrCode :: internal ( " " , StatusCode :: INTERNAL_SERVER_ERROR ) , PrimaryKeyAlreadyPresent => ErrCode :: internal ( " " , StatusCode :: INTERNAL_SERVER_ERROR ) , // invalid document MaxFieldsLimitExceeded => ErrCode :: invalid ( " " , StatusCode :: BAD_REQUEST ) , MissingDocumentId => ErrCode :: invalid ( " " , StatusCode :: BAD_REQUEST ) , Facet => ErrCode :: invalid ( " " , StatusCode :: BAD_REQUEST ) , Filter => ErrCode :: invalid ( " " , StatusCode :: BAD_REQUEST ) , BadParameter => ErrCode :: invalid ( " " , StatusCode :: BAD_REQUEST ) , BadRequest => ErrCode :: invalid ( " " , StatusCode :: BAD_REQUEST ) , DocumentNotFound => ErrCode :: internal ( " " , StatusCode :: NOT_FOUND ) , Internal => ErrCode :: internal ( " " , StatusCode :: INTERNAL_SERVER_ERROR ) , InvalidToken => ErrCode :: authentication ( " " , StatusCode :: FORBIDDEN ) , Maintenance => ErrCode :: internal ( " " , StatusCode :: SERVICE_UNAVAILABLE ) , MissingAuthorizationHeader => ErrCode :: authentication ( " " , StatusCode :: UNAUTHORIZED ) , NotFound => ErrCode :: invalid ( " " , StatusCode :: NOT_FOUND ) , PayloadTooLarge => ErrCode :: invalid ( " " , StatusCode :: PAYLOAD_TOO_LARGE ) , RetrieveDocument => ErrCode :: internal ( " " , StatusCode :: BAD_REQUEST ) , SearchDocuments => ErrCode :: internal ( " " , StatusCode :: BAD_REQUEST ) , UnsupportedMediaType => ErrCode :: invalid ( " " , StatusCode :: UNSUPPORTED_MEDIA_TYPE ) , } }
ascociate a `Code` variant to the actual ErrCode
ascociate a ` Code ` variant to the actual ErrCode
&self
&self