error.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // Code generated by go-swagger; DO NOT EDIT.
  2. package models
  3. // This file was generated by the swagger tool.
  4. // Editing this file might prove futile when you re-run the swagger generate command
  5. import (
  6. "context"
  7. "github.com/go-openapi/errors"
  8. "github.com/go-openapi/strfmt"
  9. "github.com/go-openapi/swag"
  10. "github.com/go-openapi/validate"
  11. )
  12. // Error error
  13. //
  14. // swagger:model error
  15. type Error struct {
  16. // code
  17. Code int64 `json:"code,omitempty"`
  18. // message
  19. // Required: true
  20. Message *string `json:"message"`
  21. }
  22. // Validate validates this error
  23. func (m *Error) Validate(formats strfmt.Registry) error {
  24. var res []error
  25. if err := m.validateMessage(formats); err != nil {
  26. res = append(res, err)
  27. }
  28. if len(res) > 0 {
  29. return errors.CompositeValidationError(res...)
  30. }
  31. return nil
  32. }
  33. func (m *Error) validateMessage(formats strfmt.Registry) error {
  34. if err := validate.Required("message", "body", m.Message); err != nil {
  35. return err
  36. }
  37. return nil
  38. }
  39. // ContextValidate validates this error based on context it is used
  40. func (m *Error) ContextValidate(ctx context.Context, formats strfmt.Registry) error {
  41. return nil
  42. }
  43. // MarshalBinary interface implementation
  44. func (m *Error) MarshalBinary() ([]byte, error) {
  45. if m == nil {
  46. return nil, nil
  47. }
  48. return swag.WriteJSON(m)
  49. }
  50. // UnmarshalBinary interface implementation
  51. func (m *Error) UnmarshalBinary(b []byte) error {
  52. var res Error
  53. if err := swag.ReadJSON(b, &res); err != nil {
  54. return err
  55. }
  56. *m = res
  57. return nil
  58. }