github.com/weaviate/weaviate@v1.24.6/entities/models/graph_q_l_error.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  // GraphQLError An error response caused by a GraphQL query.
    29  //
    30  // swagger:model GraphQLError
    31  type GraphQLError struct {
    32  
    33  	// locations
    34  	Locations []*GraphQLErrorLocationsItems0 `json:"locations"`
    35  
    36  	// message
    37  	Message string `json:"message,omitempty"`
    38  
    39  	// path
    40  	Path []string `json:"path"`
    41  }
    42  
    43  // Validate validates this graph q l error
    44  func (m *GraphQLError) Validate(formats strfmt.Registry) error {
    45  	var res []error
    46  
    47  	if err := m.validateLocations(formats); err != nil {
    48  		res = append(res, err)
    49  	}
    50  
    51  	if len(res) > 0 {
    52  		return errors.CompositeValidationError(res...)
    53  	}
    54  	return nil
    55  }
    56  
    57  func (m *GraphQLError) validateLocations(formats strfmt.Registry) error {
    58  	if swag.IsZero(m.Locations) { // not required
    59  		return nil
    60  	}
    61  
    62  	for i := 0; i < len(m.Locations); i++ {
    63  		if swag.IsZero(m.Locations[i]) { // not required
    64  			continue
    65  		}
    66  
    67  		if m.Locations[i] != nil {
    68  			if err := m.Locations[i].Validate(formats); err != nil {
    69  				if ve, ok := err.(*errors.Validation); ok {
    70  					return ve.ValidateName("locations" + "." + strconv.Itoa(i))
    71  				} else if ce, ok := err.(*errors.CompositeError); ok {
    72  					return ce.ValidateName("locations" + "." + strconv.Itoa(i))
    73  				}
    74  				return err
    75  			}
    76  		}
    77  
    78  	}
    79  
    80  	return nil
    81  }
    82  
    83  // ContextValidate validate this graph q l error based on the context it is used
    84  func (m *GraphQLError) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
    85  	var res []error
    86  
    87  	if err := m.contextValidateLocations(ctx, formats); err != nil {
    88  		res = append(res, err)
    89  	}
    90  
    91  	if len(res) > 0 {
    92  		return errors.CompositeValidationError(res...)
    93  	}
    94  	return nil
    95  }
    96  
    97  func (m *GraphQLError) contextValidateLocations(ctx context.Context, formats strfmt.Registry) error {
    98  
    99  	for i := 0; i < len(m.Locations); i++ {
   100  
   101  		if m.Locations[i] != nil {
   102  			if err := m.Locations[i].ContextValidate(ctx, formats); err != nil {
   103  				if ve, ok := err.(*errors.Validation); ok {
   104  					return ve.ValidateName("locations" + "." + strconv.Itoa(i))
   105  				} else if ce, ok := err.(*errors.CompositeError); ok {
   106  					return ce.ValidateName("locations" + "." + strconv.Itoa(i))
   107  				}
   108  				return err
   109  			}
   110  		}
   111  
   112  	}
   113  
   114  	return nil
   115  }
   116  
   117  // MarshalBinary interface implementation
   118  func (m *GraphQLError) MarshalBinary() ([]byte, error) {
   119  	if m == nil {
   120  		return nil, nil
   121  	}
   122  	return swag.WriteJSON(m)
   123  }
   124  
   125  // UnmarshalBinary interface implementation
   126  func (m *GraphQLError) UnmarshalBinary(b []byte) error {
   127  	var res GraphQLError
   128  	if err := swag.ReadJSON(b, &res); err != nil {
   129  		return err
   130  	}
   131  	*m = res
   132  	return nil
   133  }
   134  
   135  // GraphQLErrorLocationsItems0 graph q l error locations items0
   136  //
   137  // swagger:model GraphQLErrorLocationsItems0
   138  type GraphQLErrorLocationsItems0 struct {
   139  
   140  	// column
   141  	Column int64 `json:"column,omitempty"`
   142  
   143  	// line
   144  	Line int64 `json:"line,omitempty"`
   145  }
   146  
   147  // Validate validates this graph q l error locations items0
   148  func (m *GraphQLErrorLocationsItems0) Validate(formats strfmt.Registry) error {
   149  	return nil
   150  }
   151  
   152  // ContextValidate validates this graph q l error locations items0 based on context it is used
   153  func (m *GraphQLErrorLocationsItems0) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
   154  	return nil
   155  }
   156  
   157  // MarshalBinary interface implementation
   158  func (m *GraphQLErrorLocationsItems0) MarshalBinary() ([]byte, error) {
   159  	if m == nil {
   160  		return nil, nil
   161  	}
   162  	return swag.WriteJSON(m)
   163  }
   164  
   165  // UnmarshalBinary interface implementation
   166  func (m *GraphQLErrorLocationsItems0) UnmarshalBinary(b []byte) error {
   167  	var res GraphQLErrorLocationsItems0
   168  	if err := swag.ReadJSON(b, &res); err != nil {
   169  		return err
   170  	}
   171  	*m = res
   172  	return nil
   173  }