@@ -68,6 +68,12 @@ def detect_faces(path):
68
68
for vertex in face .bounding_poly .vertices ])
69
69
70
70
print ('face bounds: {}' .format (',' .join (vertices )))
71
+
72
+ if response .error .message :
73
+ raise Exception (
74
+ '{}\n For more info on error messages, check: '
75
+ 'https://cloud.google.com/apis/design/errors' .format (
76
+ response .error .message ))
71
77
# [END vision_python_migration_face_detection]
72
78
# [END vision_face_detection]
73
79
@@ -99,6 +105,12 @@ def detect_faces_uri(uri):
99
105
for vertex in face .bounding_poly .vertices ])
100
106
101
107
print ('face bounds: {}' .format (',' .join (vertices )))
108
+
109
+ if response .error .message :
110
+ raise Exception (
111
+ '{}\n For more info on error messages, check: '
112
+ 'https://cloud.google.com/apis/design/errors' .format (
113
+ response .error .message ))
102
114
# [END vision_face_detection_gcs]
103
115
104
116
@@ -121,6 +133,12 @@ def detect_labels(path):
121
133
122
134
for label in labels :
123
135
print (label .description )
136
+
137
+ if response .error .message :
138
+ raise Exception (
139
+ '{}\n For more info on error messages, check: '
140
+ 'https://cloud.google.com/apis/design/errors' .format (
141
+ response .error .message ))
124
142
# [END vision_python_migration_label_detection]
125
143
# [END vision_label_detection]
126
144
@@ -140,6 +158,12 @@ def detect_labels_uri(uri):
140
158
141
159
for label in labels :
142
160
print (label .description )
161
+
162
+ if response .error .message :
163
+ raise Exception (
164
+ '{}\n For more info on error messages, check: '
165
+ 'https://cloud.google.com/apis/design/errors' .format (
166
+ response .error .message ))
143
167
# [END vision_label_detection_gcs]
144
168
145
169
@@ -166,6 +190,12 @@ def detect_landmarks(path):
166
190
lat_lng = location .lat_lng
167
191
print ('Latitude {}' .format (lat_lng .latitude ))
168
192
print ('Longitude {}' .format (lat_lng .longitude ))
193
+
194
+ if response .error .message :
195
+ raise Exception (
196
+ '{}\n For more info on error messages, check: '
197
+ 'https://cloud.google.com/apis/design/errors' .format (
198
+ response .error .message ))
169
199
# [END vision_python_migration_landmark_detection]
170
200
# [END vision_landmark_detection]
171
201
@@ -185,6 +215,12 @@ def detect_landmarks_uri(uri):
185
215
186
216
for landmark in landmarks :
187
217
print (landmark .description )
218
+
219
+ if response .error .message :
220
+ raise Exception (
221
+ '{}\n For more info on error messages, check: '
222
+ 'https://cloud.google.com/apis/design/errors' .format (
223
+ response .error .message ))
188
224
# [END vision_landmark_detection_gcs]
189
225
190
226
@@ -207,6 +243,12 @@ def detect_logos(path):
207
243
208
244
for logo in logos :
209
245
print (logo .description )
246
+
247
+ if response .error .message :
248
+ raise Exception (
249
+ '{}\n For more info on error messages, check: '
250
+ 'https://cloud.google.com/apis/design/errors' .format (
251
+ response .error .message ))
210
252
# [END vision_python_migration_logo_detection]
211
253
# [END vision_logo_detection]
212
254
@@ -226,6 +268,12 @@ def detect_logos_uri(uri):
226
268
227
269
for logo in logos :
228
270
print (logo .description )
271
+
272
+ if response .error .message :
273
+ raise Exception (
274
+ '{}\n For more info on error messages, check: '
275
+ 'https://cloud.google.com/apis/design/errors' .format (
276
+ response .error .message ))
229
277
# [END vision_logo_detection_gcs]
230
278
231
279
@@ -255,6 +303,12 @@ def detect_safe_search(path):
255
303
print ('spoofed: {}' .format (likelihood_name [safe .spoof ]))
256
304
print ('violence: {}' .format (likelihood_name [safe .violence ]))
257
305
print ('racy: {}' .format (likelihood_name [safe .racy ]))
306
+
307
+ if response .error .message :
308
+ raise Exception (
309
+ '{}\n For more info on error messages, check: '
310
+ 'https://cloud.google.com/apis/design/errors' .format (
311
+ response .error .message ))
258
312
# [END vision_python_migration_safe_search_detection]
259
313
# [END vision_safe_search_detection]
260
314
@@ -281,6 +335,12 @@ def detect_safe_search_uri(uri):
281
335
print ('spoofed: {}' .format (likelihood_name [safe .spoof ]))
282
336
print ('violence: {}' .format (likelihood_name [safe .violence ]))
283
337
print ('racy: {}' .format (likelihood_name [safe .racy ]))
338
+
339
+ if response .error .message :
340
+ raise Exception (
341
+ '{}\n For more info on error messages, check: '
342
+ 'https://cloud.google.com/apis/design/errors' .format (
343
+ response .error .message ))
284
344
# [END vision_safe_search_detection_gcs]
285
345
286
346
@@ -308,6 +368,12 @@ def detect_text(path):
308
368
for vertex in text .bounding_poly .vertices ])
309
369
310
370
print ('bounds: {}' .format (',' .join (vertices )))
371
+
372
+ if response .error .message :
373
+ raise Exception (
374
+ '{}\n For more info on error messages, check: '
375
+ 'https://cloud.google.com/apis/design/errors' .format (
376
+ response .error .message ))
311
377
# [END vision_python_migration_text_detection]
312
378
# [END vision_text_detection]
313
379
@@ -332,6 +398,12 @@ def detect_text_uri(uri):
332
398
for vertex in text .bounding_poly .vertices ])
333
399
334
400
print ('bounds: {}' .format (',' .join (vertices )))
401
+
402
+ if response .error .message :
403
+ raise Exception (
404
+ '{}\n For more info on error messages, check: '
405
+ 'https://cloud.google.com/apis/design/errors' .format (
406
+ response .error .message ))
335
407
# [END vision_text_detection_gcs]
336
408
337
409
@@ -358,6 +430,12 @@ def detect_properties(path):
358
430
print ('\t g: {}' .format (color .color .green ))
359
431
print ('\t b: {}' .format (color .color .blue ))
360
432
print ('\t a: {}' .format (color .color .alpha ))
433
+
434
+ if response .error .message :
435
+ raise Exception (
436
+ '{}\n For more info on error messages, check: '
437
+ 'https://cloud.google.com/apis/design/errors' .format (
438
+ response .error .message ))
361
439
# [END vision_python_migration_image_properties]
362
440
# [END vision_image_property_detection]
363
441
@@ -381,6 +459,12 @@ def detect_properties_uri(uri):
381
459
print ('\t g: {}' .format (color .color .green ))
382
460
print ('\t b: {}' .format (color .color .blue ))
383
461
print ('\t a: {}' .format (color .color .alpha ))
462
+
463
+ if response .error .message :
464
+ raise Exception (
465
+ '{}\n For more info on error messages, check: '
466
+ 'https://cloud.google.com/apis/design/errors' .format (
467
+ response .error .message ))
384
468
# [END vision_image_property_detection_gcs]
385
469
386
470
@@ -439,6 +523,12 @@ def detect_web(path):
439
523
440
524
for image in annotations .visually_similar_images :
441
525
print ('\t Image url : {}' .format (image .url ))
526
+
527
+ if response .error .message :
528
+ raise Exception (
529
+ '{}\n For more info on error messages, check: '
530
+ 'https://cloud.google.com/apis/design/errors' .format (
531
+ response .error .message ))
442
532
# [END vision_python_migration_web_detection]
443
533
# [END vision_web_detection]
444
534
@@ -493,6 +583,12 @@ def detect_web_uri(uri):
493
583
494
584
for image in annotations .visually_similar_images :
495
585
print ('\t Image url : {}' .format (image .url ))
586
+
587
+ if response .error .message :
588
+ raise Exception (
589
+ '{}\n For more info on error messages, check: '
590
+ 'https://cloud.google.com/apis/design/errors' .format (
591
+ response .error .message ))
496
592
# [END vision_web_detection_gcs]
497
593
498
594
@@ -519,6 +615,12 @@ def web_entities_include_geo_results(path):
519
615
for entity in response .web_detection .web_entities :
520
616
print ('\n \t Score : {}' .format (entity .score ))
521
617
print (u'\t Description: {}' .format (entity .description ))
618
+
619
+ if response .error .message :
620
+ raise Exception (
621
+ '{}\n For more info on error messages, check: '
622
+ 'https://cloud.google.com/apis/design/errors' .format (
623
+ response .error .message ))
522
624
# [END vision_web_detection_include_geo]
523
625
524
626
@@ -543,6 +645,12 @@ def web_entities_include_geo_results_uri(uri):
543
645
for entity in response .web_detection .web_entities :
544
646
print ('\n \t Score : {}' .format (entity .score ))
545
647
print (u'\t Description: {}' .format (entity .description ))
648
+
649
+ if response .error .message :
650
+ raise Exception (
651
+ '{}\n For more info on error messages, check: '
652
+ 'https://cloud.google.com/apis/design/errors' .format (
653
+ response .error .message ))
546
654
# [END vision_web_detection_include_geo_gcs]
547
655
548
656
@@ -572,6 +680,12 @@ def detect_crop_hints(path):
572
680
for vertex in hint .bounding_poly .vertices ])
573
681
574
682
print ('bounds: {}' .format (',' .join (vertices )))
683
+
684
+ if response .error .message :
685
+ raise Exception (
686
+ '{}\n For more info on error messages, check: '
687
+ 'https://cloud.google.com/apis/design/errors' .format (
688
+ response .error .message ))
575
689
# [END vision_python_migration_crop_hints]
576
690
# [END vision_crop_hint_detection]
577
691
@@ -598,6 +712,12 @@ def detect_crop_hints_uri(uri):
598
712
for vertex in hint .bounding_poly .vertices ])
599
713
600
714
print ('bounds: {}' .format (',' .join (vertices )))
715
+
716
+ if response .error .message :
717
+ raise Exception (
718
+ '{}\n For more info on error messages, check: '
719
+ 'https://cloud.google.com/apis/design/errors' .format (
720
+ response .error .message ))
601
721
# [END vision_crop_hint_detection_gcs]
602
722
603
723
@@ -634,6 +754,12 @@ def detect_document(path):
634
754
for symbol in word .symbols :
635
755
print ('\t Symbol: {} (confidence: {})' .format (
636
756
symbol .text , symbol .confidence ))
757
+
758
+ if response .error .message :
759
+ raise Exception (
760
+ '{}\n For more info on error messages, check: '
761
+ 'https://cloud.google.com/apis/design/errors' .format (
762
+ response .error .message ))
637
763
# [END vision_python_migration_document_text_detection]
638
764
# [END vision_fulltext_detection]
639
765
@@ -667,6 +793,12 @@ def detect_document_uri(uri):
667
793
for symbol in word .symbols :
668
794
print ('\t Symbol: {} (confidence: {})' .format (
669
795
symbol .text , symbol .confidence ))
796
+
797
+ if response .error .message :
798
+ raise Exception (
799
+ '{}\n For more info on error messages, check: '
800
+ 'https://cloud.google.com/apis/design/errors' .format (
801
+ response .error .message ))
670
802
# [END vision_fulltext_detection_gcs]
671
803
672
804
0 commit comments