Skip to content

Commit 98d83ba

Browse files
committed
CDRIVER-1434 show set_error_api in examples
# Conflicts: # examples/aggregation/aggregation1.c # examples/bulk/bulk1.c # examples/bulk/bulk2.c # examples/bulk/bulk3.c # examples/bulk/bulk4.c # examples/bulk/bulk5.c # examples/bulk/bulk6.c # examples/find-and-modify.c # examples/find_and_modify_with_opts/fam.c
1 parent a57ba29 commit 98d83ba

File tree

9 files changed

+18
-3
lines changed

9 files changed

+18
-3
lines changed

examples/basic_aggregation/basic-aggregation.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ main (int argc,
6767
goto cleanup;
6868
}
6969

70+
mongoc_client_set_error_api (client, 2);
7071
database = mongoc_client_get_database (client, "test");
7172
collection = mongoc_database_get_collection (database, COLLECTION_NAME);
7273

examples/common_operations/common-operations.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ main (int argc,
7171
goto cleanup;
7272
}
7373

74+
mongoc_client_set_error_api (client, 2);
7475
database = mongoc_client_get_database (client, "test");
7576
collection = mongoc_database_get_collection (database, COLLECTION_NAME);
7677

examples/example-application-performance-monitoring.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ main (int argc,
8686
return EXIT_FAILURE;
8787
}
8888

89+
mongoc_client_set_error_api (client, 2);
8990
callbacks = mongoc_apm_callbacks_new ();
9091
mongoc_apm_set_command_started_cb (callbacks, command_started);
9192
mongoc_apm_set_command_succeeded_cb (callbacks, command_succeeded );

examples/example-client.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ main (int argc,
3737
return EXIT_FAILURE;
3838
}
3939

40+
mongoc_client_set_error_api (client, 2);
41+
4042
bson_init (&query);
4143

4244
#if 0

examples/example-gridfs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ int main (int argc, char *argv[])
3434
/* connect to localhost client */
3535
client = mongoc_client_new ("mongodb://127.0.0.1:27017");
3636
assert(client);
37+
mongoc_client_set_error_api (client, 2);
3738

3839
/* grab a gridfs handle in test prefixed by fs */
3940
gridfs = mongoc_client_get_gridfs (client, "test", "fs", &error);

examples/example-scram.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ main (int argc,
4949
goto CLEANUP;
5050
}
5151

52+
mongoc_client_set_error_api (client, 2);
53+
5254
database = mongoc_client_get_database (client, "test");
5355

5456
BCON_APPEND (&roles,
@@ -60,7 +62,6 @@ main (int argc,
6062
database = NULL;
6163

6264
mongoc_client_destroy (client);
63-
client = NULL;
6465

6566
client = mongoc_client_new (authuristr);
6667

@@ -69,6 +70,8 @@ main (int argc,
6970
goto CLEANUP;
7071
}
7172

73+
mongoc_client_set_error_api (client, 2);
74+
7275
collection = mongoc_client_get_collection (client, "test", "test");
7376

7477
cursor = mongoc_collection_find (collection, (mongoc_query_flags_t)0, 0, 0, 0, &query, NULL, NULL);

examples/mongoc-dump.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,8 @@ main (int argc,
250250
return EXIT_FAILURE;
251251
}
252252

253+
mongoc_client_set_error_api (client, 2);
254+
253255
ret = mongoc_dump (client, database, collection);
254256

255257
mongoc_client_destroy (client);

examples/mongoc-ping.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ main (int argc,
5555
return 2;
5656
}
5757

58+
mongoc_client_set_error_api (client, 2);
59+
5860
bson_init(&ping);
5961
bson_append_int32(&ping, "ping", 4, 1);
6062
database = mongoc_client_get_database(client, "test");

examples/mongoc-tail.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ tail_collection (mongoc_collection_t *collection)
7878
}
7979
}
8080
if (mongoc_cursor_error(cursor, &error)) {
81-
if ((error.domain == MONGOC_ERROR_QUERY) &&
82-
(error.code == MONGOC_ERROR_QUERY_NOT_TAILABLE)) {
81+
if (error.domain == MONGOC_ERROR_SERVER) {
8382
fprintf(stderr, "%s\n", error.message);
8483
exit(1);
8584
}
8685
}
86+
8787
mongoc_cursor_destroy(cursor);
8888
sleep(1);
8989
}
@@ -110,6 +110,8 @@ main (int argc,
110110
return EXIT_FAILURE;
111111
}
112112

113+
mongoc_client_set_error_api (client, 2);
114+
113115
collection = mongoc_client_get_collection(client, "local", "oplog.rs");
114116

115117
tail_collection(collection);

0 commit comments

Comments
 (0)