MCPcopy Create free account
hub / github.com/goadesign/goa / ErrorName

Function ErrorName

dsl/error.go:174–207  ·  view source on GitHub ↗

ErrorName identifies the attribute of a custom error type used to select the returned error response when multiple errors of that type are defined on the same method. The value of the field identifies the error name as defined in the design. This makes it possible to define distinct transport mappin

(args ...any)

Source from the content-addressed store, hash-verified

172// return nil
173// }
174func ErrorName(args ...any) {
175 if len(args) == 0 {
176 eval.TooFewArgError()
177 return
178 }
179 dsl, ok := args[len(args)-1].(func())
180 if ok {
181 args[len(args)-1] = func() {
182 dsl()
183 Meta("struct:error:name")
184 }
185 } else {
186 args = append(args, func() {
187 Meta("struct:error:name")
188 })
189 }
190 switch actual := args[0].(type) {
191 case string:
192 Attribute(actual, args[1:]...)
193 case int:
194 if len(args) == 2 {
195 eval.TooFewArgError()
196 return
197 }
198 name, ok := args[1].(string)
199 if !ok {
200 eval.InvalidArgError("name", args[1])
201 return
202 }
203 Field(actual, name, args[2:]...)
204 default:
205 eval.InvalidArgError("name or position", args[0])
206 }
207}
208
209// Temporary qualifies an error type as describing temporary (i.e. retryable)
210// errors.

Callers 9

result_dsls.goFile · 0.85
dsls.goFile · 0.85
TestInvalidArgErrorFunction · 0.85
TestTooFewArgErrorFunction · 0.85
TestTooManyArgErrorFunction · 0.85
service_dsls.goFile · 0.85

Calls 5

TooFewArgErrorFunction · 0.92
InvalidArgErrorFunction · 0.92
MetaFunction · 0.85
AttributeFunction · 0.85
FieldFunction · 0.85

Tested by 4

TestInvalidArgErrorFunction · 0.68
TestTooFewArgErrorFunction · 0.68
TestTooManyArgErrorFunction · 0.68