Skip to content

Commit dc5af4e

Browse files
authored
fix: make iter error handling clearer (#1561)
1 parent ae37381 commit dc5af4e

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

internal/gengapic/example.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ func (g *generator) examplePagingAllCall(m *descriptorpb.MethodDescriptorProto)
333333

334334
p("for resp, err := range c.%s(ctx, req).All() {", m.GetName())
335335
p(" if err != nil {")
336-
p(" // TODO: Handle error.")
336+
p(" // TODO: Handle error and break/return/continue. Iteration will stop after any error.")
337337
p(" }")
338338
p(" // TODO: Use resp.")
339339
p(" _ = resp")

internal/gengapic/testdata/custom_op_example_all.want

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func ExampleFooClient_GetManyThings_all() {
1717
}
1818
for resp, err := range c.GetManyThings(ctx, req).All() {
1919
if err != nil {
20-
// TODO: Handle error.
20+
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
2121
}
2222
// TODO: Use resp.
2323
_ = resp

internal/gengapic/testdata/empty_example_all.want

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func ExampleClient_GetManyThings_all() {
1717
}
1818
for resp, err := range c.GetManyThings(ctx, req).All() {
1919
if err != nil {
20-
// TODO: Handle error.
20+
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
2121
}
2222
// TODO: Use resp.
2323
_ = resp
@@ -43,7 +43,7 @@ func ExampleClient_ListLocations_all() {
4343
}
4444
for resp, err := range c.ListLocations(ctx, req).All() {
4545
if err != nil {
46-
// TODO: Handle error.
46+
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
4747
}
4848
// TODO: Use resp.
4949
_ = resp
@@ -69,7 +69,7 @@ func ExampleClient_ListOperations_all() {
6969
}
7070
for resp, err := range c.ListOperations(ctx, req).All() {
7171
if err != nil {
72-
// TODO: Handle error.
72+
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
7373
}
7474
// TODO: Use resp.
7575
_ = resp

internal/gengapic/testdata/empty_example_grpc_all.want

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func ExampleClient_GetManyThings_all() {
1717
}
1818
for resp, err := range c.GetManyThings(ctx, req).All() {
1919
if err != nil {
20-
// TODO: Handle error.
20+
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
2121
}
2222
// TODO: Use resp.
2323
_ = resp
@@ -43,7 +43,7 @@ func ExampleClient_ListLocations_all() {
4343
}
4444
for resp, err := range c.ListLocations(ctx, req).All() {
4545
if err != nil {
46-
// TODO: Handle error.
46+
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
4747
}
4848
// TODO: Use resp.
4949
_ = resp
@@ -69,7 +69,7 @@ func ExampleClient_ListOperations_all() {
6969
}
7070
for resp, err := range c.ListOperations(ctx, req).All() {
7171
if err != nil {
72-
// TODO: Handle error.
72+
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
7373
}
7474
// TODO: Use resp.
7575
_ = resp

internal/gengapic/testdata/foo_example_all.want

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func ExampleFooClient_GetManyThings_all() {
1717
}
1818
for resp, err := range c.GetManyThings(ctx, req).All() {
1919
if err != nil {
20-
// TODO: Handle error.
20+
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
2121
}
2222
// TODO: Use resp.
2323
_ = resp
@@ -43,7 +43,7 @@ func ExampleFooClient_ListLocations_all() {
4343
}
4444
for resp, err := range c.ListLocations(ctx, req).All() {
4545
if err != nil {
46-
// TODO: Handle error.
46+
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
4747
}
4848
// TODO: Use resp.
4949
_ = resp
@@ -69,7 +69,7 @@ func ExampleFooClient_ListOperations_all() {
6969
}
7070
for resp, err := range c.ListOperations(ctx, req).All() {
7171
if err != nil {
72-
// TODO: Handle error.
72+
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
7373
}
7474
// TODO: Use resp.
7575
_ = resp

internal/gengapic/testdata/foo_example_rest_all.want

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func ExampleFooClient_GetManyThings_all() {
1717
}
1818
for resp, err := range c.GetManyThings(ctx, req).All() {
1919
if err != nil {
20-
// TODO: Handle error.
20+
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
2121
}
2222
// TODO: Use resp.
2323
_ = resp
@@ -43,7 +43,7 @@ func ExampleFooClient_ListLocations_all() {
4343
}
4444
for resp, err := range c.ListLocations(ctx, req).All() {
4545
if err != nil {
46-
// TODO: Handle error.
46+
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
4747
}
4848
// TODO: Use resp.
4949
_ = resp
@@ -69,7 +69,7 @@ func ExampleFooClient_ListOperations_all() {
6969
}
7070
for resp, err := range c.ListOperations(ctx, req).All() {
7171
if err != nil {
72-
// TODO: Handle error.
72+
// TODO: Handle error and break/return/continue. Iteration will stop after any error.
7373
}
7474
// TODO: Use resp.
7575
_ = resp

0 commit comments

Comments
 (0)