Skip to content

Commit 3500d8e

Browse files
committed
GODRIVER-2758: Use log.Fatal instead of panic
1 parent 3a21e18 commit 3500d8e

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

mongo/client_examples_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ func ExampleConnect_aWS() {
293293
context.TODO(),
294294
options.Client().SetAuth(awsCredential))
295295
if err != nil {
296-
panic(err)
296+
log.Fatal(err)
297297
}
298298
_ = awsIAMClient
299299

@@ -315,7 +315,7 @@ func ExampleConnect_aWS() {
315315
context.TODO(),
316316
options.Client().SetAuth(assumeRoleCredential))
317317
if err != nil {
318-
panic(err)
318+
log.Fatal(err)
319319
}
320320
_ = assumeRoleClient
321321

@@ -337,7 +337,7 @@ func ExampleConnect_aWS() {
337337
context.TODO(),
338338
options.Client().SetAuth(envVariablesCredential))
339339
if err != nil {
340-
panic(err)
340+
log.Fatal(err)
341341
}
342342
_ = envVariablesClient
343343

@@ -355,7 +355,7 @@ func ExampleConnect_aWS() {
355355
context.TODO(),
356356
options.Client().SetAuth(ecCredential))
357357
if err != nil {
358-
panic(err)
358+
log.Fatal(err)
359359
}
360360
_ = ecClient
361361
}
@@ -386,7 +386,7 @@ func ExampleConnect_stableAPI() {
386386
context.TODO(),
387387
options.Client().SetServerAPIOptions(serverAPI))
388388
if err != nil {
389-
panic(err)
389+
log.Fatal(err)
390390
}
391391
_ = serverAPIClient
392392

@@ -401,7 +401,7 @@ func ExampleConnect_stableAPI() {
401401
context.TODO(),
402402
options.Client().SetServerAPIOptions(serverAPIStrict))
403403
if err != nil {
404-
panic(err)
404+
log.Fatal(err)
405405
}
406406

407407
coll := serverAPIStrictClient.Database("db").Collection("coll")
@@ -420,7 +420,7 @@ func ExampleConnect_stableAPI() {
420420
context.TODO(),
421421
options.Client().SetServerAPIOptions(serverAPIDeprecation))
422422
if err != nil {
423-
panic(err)
423+
log.Fatal(err)
424424
}
425425
_ = serverAPIDeprecationClient
426426
}
@@ -445,11 +445,11 @@ func ExampleConnect_bSONOptions() {
445445

446446
client, err := mongo.Connect(context.TODO(), clientOpts)
447447
if err != nil {
448-
panic(err)
448+
log.Fatal(err)
449449
}
450450
defer func() {
451451
if err := client.Disconnect(context.TODO()); err != nil {
452-
panic(err)
452+
log.Fatal(err)
453453
}
454454
}()
455455

@@ -466,7 +466,7 @@ func ExampleConnect_bSONOptions() {
466466
// resulting BSON document to have a structure like {"a": {}, "b": []}
467467
_, err = coll.InsertOne(context.TODO(), myDocument{})
468468
if err != nil {
469-
panic(err)
469+
log.Fatal(err)
470470
}
471471
}
472472

@@ -504,7 +504,7 @@ func ExampleConnect_oIDC() {
504504
)
505505
c, err := mongo.Connect(context.TODO(), opts)
506506
if err != nil {
507-
panic(err)
507+
log.Fatal(err)
508508
}
509509
defer c.Disconnect(context.TODO())
510510
c.Database("test").Collection("test").InsertOne(context.TODO(), bson.D{})
@@ -530,7 +530,7 @@ func ExampleConnect_oIDC() {
530530
)
531531
c, err := mongo.Connect(context.TODO(), opts)
532532
if err != nil {
533-
panic(err)
533+
log.Fatal(err)
534534
}
535535
defer c.Disconnect(context.TODO())
536536
c.Database("test").Collection("test").InsertOne(context.TODO(), bson.D{})
@@ -568,7 +568,7 @@ func ExampleConnect_oIDC() {
568568
)
569569
c, err := mongo.Connect(context.TODO(), opts)
570570
if err != nil {
571-
panic(err)
571+
log.Fatal(err)
572572
}
573573
defer c.Disconnect(context.TODO())
574574
c.Database("test").Collection("test").InsertOne(context.TODO(), bson.D{})
@@ -608,7 +608,7 @@ func ExampleConnect_oIDC() {
608608
)
609609
c, err := mongo.Connect(context.TODO(), opts)
610610
if err != nil {
611-
panic(err)
611+
log.Fatal(err)
612612
}
613613
defer c.Disconnect(context.TODO())
614614
c.Database("test").Collection("test").InsertOne(context.TODO(), bson.D{})
@@ -649,7 +649,7 @@ func ExampleConnect_oIDC() {
649649
)
650650
c, err := mongo.Connect(context.TODO(), opts)
651651
if err != nil {
652-
panic(err)
652+
log.Fatal(err)
653653
}
654654
defer c.Disconnect(context.TODO())
655655
c.Database("test").Collection("test").InsertOne(context.TODO(), bson.D{})

0 commit comments

Comments
 (0)