github.com/weaviate/weaviate@v1.24.6/entities/models/error_response.go (about) 1 // _ _ 2 // __ _____ __ ___ ___ __ _| |_ ___ 3 // \ \ /\ / / _ \/ _` \ \ / / |/ _` | __/ _ \ 4 // \ V V / __/ (_| |\ V /| | (_| | || __/ 5 // \_/\_/ \___|\__,_| \_/ |_|\__,_|\__\___| 6 // 7 // Copyright © 2016 - 2024 Weaviate B.V. All rights reserved. 8 // 9 // CONTACT: hello@weaviate.io 10 // 11 12 // Code generated by go-swagger; DO NOT EDIT. 13 14 package models 15 16 // This file was generated by the swagger tool. 17 // Editing this file might prove futile when you re-run the swagger generate command 18 19 import ( 20 "context" 21 "strconv" 22 23 "github.com/go-openapi/errors" 24 "github.com/go-openapi/strfmt" 25 "github.com/go-openapi/swag" 26 ) 27 28 // ErrorResponse An error response given by Weaviate end-points. 29 // 30 // swagger:model ErrorResponse 31 type ErrorResponse struct { 32 33 // error 34 Error []*ErrorResponseErrorItems0 `json:"error"` 35 } 36 37 // Validate validates this error response 38 func (m *ErrorResponse) Validate(formats strfmt.Registry) error { 39 var res []error 40 41 if err := m.validateError(formats); err != nil { 42 res = append(res, err) 43 } 44 45 if len(res) > 0 { 46 return errors.CompositeValidationError(res...) 47 } 48 return nil 49 } 50 51 func (m *ErrorResponse) validateError(formats strfmt.Registry) error { 52 if swag.IsZero(m.Error) { // not required 53 return nil 54 } 55 56 for i := 0; i < len(m.Error); i++ { 57 if swag.IsZero(m.Error[i]) { // not required 58 continue 59 } 60 61 if m.Error[i] != nil { 62 if err := m.Error[i].Validate(formats); err != nil { 63 if ve, ok := err.(*errors.Validation); ok { 64 return ve.ValidateName("error" + "." + strconv.Itoa(i)) 65 } else if ce, ok := err.(*errors.CompositeError); ok { 66 return ce.ValidateName("error" + "." + strconv.Itoa(i)) 67 } 68 return err 69 } 70 } 71 72 } 73 74 return nil 75 } 76 77 // ContextValidate validate this error response based on the context it is used 78 func (m *ErrorResponse) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 79 var res []error 80 81 if err := m.contextValidateError(ctx, formats); err != nil { 82 res = append(res, err) 83 } 84 85 if len(res) > 0 { 86 return errors.CompositeValidationError(res...) 87 } 88 return nil 89 } 90 91 func (m *ErrorResponse) contextValidateError(ctx context.Context, formats strfmt.Registry) error { 92 93 for i := 0; i < len(m.Error); i++ { 94 95 if m.Error[i] != nil { 96 if err := m.Error[i].ContextValidate(ctx, formats); err != nil { 97 if ve, ok := err.(*errors.Validation); ok { 98 return ve.ValidateName("error" + "." + strconv.Itoa(i)) 99 } else if ce, ok := err.(*errors.CompositeError); ok { 100 return ce.ValidateName("error" + "." + strconv.Itoa(i)) 101 } 102 return err 103 } 104 } 105 106 } 107 108 return nil 109 } 110 111 // MarshalBinary interface implementation 112 func (m *ErrorResponse) MarshalBinary() ([]byte, error) { 113 if m == nil { 114 return nil, nil 115 } 116 return swag.WriteJSON(m) 117 } 118 119 // UnmarshalBinary interface implementation 120 func (m *ErrorResponse) UnmarshalBinary(b []byte) error { 121 var res ErrorResponse 122 if err := swag.ReadJSON(b, &res); err != nil { 123 return err 124 } 125 *m = res 126 return nil 127 } 128 129 // ErrorResponseErrorItems0 error response error items0 130 // 131 // swagger:model ErrorResponseErrorItems0 132 type ErrorResponseErrorItems0 struct { 133 134 // message 135 Message string `json:"message,omitempty"` 136 } 137 138 // Validate validates this error response error items0 139 func (m *ErrorResponseErrorItems0) Validate(formats strfmt.Registry) error { 140 return nil 141 } 142 143 // ContextValidate validates this error response error items0 based on context it is used 144 func (m *ErrorResponseErrorItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error { 145 return nil 146 } 147 148 // MarshalBinary interface implementation 149 func (m *ErrorResponseErrorItems0) MarshalBinary() ([]byte, error) { 150 if m == nil { 151 return nil, nil 152 } 153 return swag.WriteJSON(m) 154 } 155 156 // UnmarshalBinary interface implementation 157 func (m *ErrorResponseErrorItems0) UnmarshalBinary(b []byte) error { 158 var res ErrorResponseErrorItems0 159 if err := swag.ReadJSON(b, &res); err != nil { 160 return err 161 } 162 *m = res 163 return nil 164 }