@@ -141,6 +141,10 @@ type ProblemControls struct {
141
141
// of errors from the error it comes from (if any).
142
142
Errors ProblemControlsResolver [bool ]
143
143
144
+ // ErrorsKey determines the key to use when appending the
145
+ // error stack when [ProblemControls]'s Errors returns true.
146
+ ErrorsKey ProblemControlsResolver [string ]
147
+
144
148
// Response allows customizing the actual Builder response
145
149
// that a [Problem] should be resolved to.
146
150
Response ProblemControlsResolver [Builder ]
@@ -181,6 +185,10 @@ func defaultedProblemControls(controls ProblemControls) ProblemControls {
181
185
controls .Errors = defaultProblemControlsErrors
182
186
}
183
187
188
+ if controls .ErrorsKey == nil {
189
+ controls .ErrorsKey = defaultProblemControlsErrorsKey
190
+ }
191
+
184
192
if controls .Response == nil {
185
193
controls .Response = defaultProblemControlsResponse
186
194
}
@@ -237,6 +245,11 @@ func defaultProblemControlsErrors(problem Problem, request *http.Request) bool {
237
245
return true
238
246
}
239
247
248
+ // defaultProblemControlsInstance is the default value for the [ProblemControls] instance.
249
+ func defaultProblemControlsErrorsKey (problem Problem , request * http.Request ) string {
250
+ return "errors"
251
+ }
252
+
240
253
// ProblemControlsResponseFrom is a helper that generates a [ProblemControlsResolver] with
241
254
// the given response content types. It is very useful to map mimes to responses.
242
255
func ProblemControlsResponseFrom (responses map [string ]Builder ) ProblemControlsResolver [Builder ] {
@@ -460,7 +473,10 @@ func (problem Problem) Defaulted(request *http.Request) Problem {
460
473
messages [i ] = trace .Error ()
461
474
}
462
475
463
- problem = problem .With ("errors" , messages )
476
+ problem = problem .With (
477
+ controls .ErrorsKey (problem , request ),
478
+ messages ,
479
+ )
464
480
}
465
481
466
482
if lower {
0 commit comments