Skip to content

Commit 9c0fecc

Browse files
committed
Add utility functions for list results stream errors
1 parent 3e5c9f7 commit 9c0fecc

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

list/list_resource.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,25 +134,16 @@ type ListResultsStream struct {
134134
// NoListResults is an iterator that pushes zero results.
135135
var NoListResults = func(func(ListResult) bool) {}
136136

137-
// ListResultsStreamError returns a function that yields a single
138-
// [[ListResult]] with an error diagnostic
139-
func ListResultsStreamError(summary string, detail string) iter.Seq[ListResult] {
137+
// ListResultsStreamDiagnostics returns a function that yields a single
138+
// [[ListResult]] with the given Diagnostics
139+
func ListResultsStreamDiagnostics(diags diag.Diagnostics) iter.Seq[ListResult] {
140140
return func(push func(ListResult) bool) {
141-
if !push(ListResultError(summary, detail)) {
141+
if !push(ListResult{Diagnostics: diags}) {
142142
return
143143
}
144144
}
145145
}
146146

147-
// ListResultError constructs a [[ListResult]] with an error diagnostic
148-
func ListResultError(summary string, detail string) ListResult {
149-
return ListResult{
150-
Diagnostics: diag.Diagnostics{
151-
diag.NewErrorDiagnostic(summary, detail),
152-
},
153-
}
154-
}
155-
156147
// ListResult represents a listed managed resource instance.
157148
type ListResult struct {
158149
// Identity is the identity of the managed resource instance.

0 commit comments

Comments
 (0)