forked from go-swagger/go-swagger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error.go
75 lines (54 loc) · 1.54 KB
/
error.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package models
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import (
"github.com/go-swagger/go-swagger/errors"
"github.com/go-swagger/go-swagger/httpkit/validate"
"github.com/go-swagger/go-swagger/strfmt"
)
/*Error Error Structure
Contains all the properties any error response from the API will contain.
Some properties are optional so might be empty most of the time
swagger:model Error
*/
type Error struct {
/* the error code, this is not necessarily the http status code
Required: true
*/
Code int32 `json:"code,omitempty"`
/* an optional url for getting more help about this error
*/
HelpURL strfmt.URI `json:"helpUrl,omitempty"`
/* a human readable version of the error
Required: true
*/
Message string `json:"message,omitempty"`
}
// Validate validates this error
func (m *Error) Validate(formats strfmt.Registry) error {
var res []error
if err := m.validateCode(formats); err != nil {
// prop
res = append(res, err)
}
if err := m.validateMessage(formats); err != nil {
// prop
res = append(res, err)
}
if len(res) > 0 {
return errors.CompositeValidationError(res...)
}
return nil
}
func (m *Error) validateCode(formats strfmt.Registry) error {
if err := validate.Required("code", "body", int32(m.Code)); err != nil {
return err
}
return nil
}
func (m *Error) validateMessage(formats strfmt.Registry) error {
if err := validate.RequiredString("message", "body", string(m.Message)); err != nil {
return err
}
return nil
}