-
Notifications
You must be signed in to change notification settings - Fork 310
/
error.pb.setters.fm.go
109 lines (105 loc) · 2.44 KB
/
error.pb.setters.fm.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// Code generated by protoc-gen-fieldmask. DO NOT EDIT.
package ttnpb
import fmt "fmt"
func (dst *ErrorDetails) SetFields(src *ErrorDetails, paths ...string) error {
for name, subs := range _processPaths(paths) {
switch name {
case "namespace":
if len(subs) > 0 {
return fmt.Errorf("'namespace' has no subfields, but %s were specified", subs)
}
if src != nil {
dst.Namespace = src.Namespace
} else {
var zero string
dst.Namespace = zero
}
case "name":
if len(subs) > 0 {
return fmt.Errorf("'name' has no subfields, but %s were specified", subs)
}
if src != nil {
dst.Name = src.Name
} else {
var zero string
dst.Name = zero
}
case "message_format":
if len(subs) > 0 {
return fmt.Errorf("'message_format' has no subfields, but %s were specified", subs)
}
if src != nil {
dst.MessageFormat = src.MessageFormat
} else {
var zero string
dst.MessageFormat = zero
}
case "attributes":
if len(subs) > 0 {
return fmt.Errorf("'attributes' has no subfields, but %s were specified", subs)
}
if src != nil {
dst.Attributes = src.Attributes
} else {
dst.Attributes = nil
}
case "correlation_id":
if len(subs) > 0 {
return fmt.Errorf("'correlation_id' has no subfields, but %s were specified", subs)
}
if src != nil {
dst.CorrelationID = src.CorrelationID
} else {
var zero string
dst.CorrelationID = zero
}
case "cause":
if len(subs) > 0 {
var newDst, newSrc *ErrorDetails
if (src == nil || src.Cause == nil) && dst.Cause == nil {
continue
}
if src != nil {
newSrc = src.Cause
}
if dst.Cause != nil {
newDst = dst.Cause
} else {
newDst = &ErrorDetails{}
dst.Cause = newDst
}
if err := newDst.SetFields(newSrc, subs...); err != nil {
return err
}
} else {
if src != nil {
dst.Cause = src.Cause
} else {
dst.Cause = nil
}
}
case "code":
if len(subs) > 0 {
return fmt.Errorf("'code' has no subfields, but %s were specified", subs)
}
if src != nil {
dst.Code = src.Code
} else {
var zero uint32
dst.Code = zero
}
case "details":
if len(subs) > 0 {
return fmt.Errorf("'details' has no subfields, but %s were specified", subs)
}
if src != nil {
dst.Details = src.Details
} else {
dst.Details = nil
}
default:
return fmt.Errorf("invalid field: '%s'", name)
}
}
return nil
}