@@ -68,6 +68,12 @@ def detect_faces(path):
6868 for vertex in face .bounding_poly .vertices ])
6969
7070 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 ))
7177 # [END vision_python_migration_face_detection]
7278# [END vision_face_detection]
7379
@@ -99,6 +105,12 @@ def detect_faces_uri(uri):
99105 for vertex in face .bounding_poly .vertices ])
100106
101107 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 ))
102114# [END vision_face_detection_gcs]
103115
104116
@@ -121,6 +133,12 @@ def detect_labels(path):
121133
122134 for label in labels :
123135 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 ))
124142 # [END vision_python_migration_label_detection]
125143# [END vision_label_detection]
126144
@@ -140,6 +158,12 @@ def detect_labels_uri(uri):
140158
141159 for label in labels :
142160 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 ))
143167# [END vision_label_detection_gcs]
144168
145169
@@ -166,6 +190,12 @@ def detect_landmarks(path):
166190 lat_lng = location .lat_lng
167191 print ('Latitude {}' .format (lat_lng .latitude ))
168192 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 ))
169199 # [END vision_python_migration_landmark_detection]
170200# [END vision_landmark_detection]
171201
@@ -185,6 +215,12 @@ def detect_landmarks_uri(uri):
185215
186216 for landmark in landmarks :
187217 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 ))
188224# [END vision_landmark_detection_gcs]
189225
190226
@@ -207,6 +243,12 @@ def detect_logos(path):
207243
208244 for logo in logos :
209245 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 ))
210252 # [END vision_python_migration_logo_detection]
211253# [END vision_logo_detection]
212254
@@ -226,6 +268,12 @@ def detect_logos_uri(uri):
226268
227269 for logo in logos :
228270 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 ))
229277# [END vision_logo_detection_gcs]
230278
231279
@@ -255,6 +303,12 @@ def detect_safe_search(path):
255303 print ('spoofed: {}' .format (likelihood_name [safe .spoof ]))
256304 print ('violence: {}' .format (likelihood_name [safe .violence ]))
257305 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 ))
258312 # [END vision_python_migration_safe_search_detection]
259313# [END vision_safe_search_detection]
260314
@@ -281,6 +335,12 @@ def detect_safe_search_uri(uri):
281335 print ('spoofed: {}' .format (likelihood_name [safe .spoof ]))
282336 print ('violence: {}' .format (likelihood_name [safe .violence ]))
283337 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 ))
284344# [END vision_safe_search_detection_gcs]
285345
286346
@@ -308,6 +368,12 @@ def detect_text(path):
308368 for vertex in text .bounding_poly .vertices ])
309369
310370 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 ))
311377 # [END vision_python_migration_text_detection]
312378# [END vision_text_detection]
313379
@@ -332,6 +398,12 @@ def detect_text_uri(uri):
332398 for vertex in text .bounding_poly .vertices ])
333399
334400 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 ))
335407# [END vision_text_detection_gcs]
336408
337409
@@ -358,6 +430,12 @@ def detect_properties(path):
358430 print ('\t g: {}' .format (color .color .green ))
359431 print ('\t b: {}' .format (color .color .blue ))
360432 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 ))
361439 # [END vision_python_migration_image_properties]
362440# [END vision_image_property_detection]
363441
@@ -381,6 +459,12 @@ def detect_properties_uri(uri):
381459 print ('\t g: {}' .format (color .color .green ))
382460 print ('\t b: {}' .format (color .color .blue ))
383461 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 ))
384468# [END vision_image_property_detection_gcs]
385469
386470
@@ -439,6 +523,12 @@ def detect_web(path):
439523
440524 for image in annotations .visually_similar_images :
441525 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 ))
442532 # [END vision_python_migration_web_detection]
443533# [END vision_web_detection]
444534
@@ -493,6 +583,12 @@ def detect_web_uri(uri):
493583
494584 for image in annotations .visually_similar_images :
495585 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 ))
496592# [END vision_web_detection_gcs]
497593
498594
@@ -519,6 +615,12 @@ def web_entities_include_geo_results(path):
519615 for entity in response .web_detection .web_entities :
520616 print ('\n \t Score : {}' .format (entity .score ))
521617 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 ))
522624# [END vision_web_detection_include_geo]
523625
524626
@@ -543,6 +645,12 @@ def web_entities_include_geo_results_uri(uri):
543645 for entity in response .web_detection .web_entities :
544646 print ('\n \t Score : {}' .format (entity .score ))
545647 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 ))
546654# [END vision_web_detection_include_geo_gcs]
547655
548656
@@ -572,6 +680,12 @@ def detect_crop_hints(path):
572680 for vertex in hint .bounding_poly .vertices ])
573681
574682 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 ))
575689 # [END vision_python_migration_crop_hints]
576690# [END vision_crop_hint_detection]
577691
@@ -598,6 +712,12 @@ def detect_crop_hints_uri(uri):
598712 for vertex in hint .bounding_poly .vertices ])
599713
600714 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 ))
601721# [END vision_crop_hint_detection_gcs]
602722
603723
@@ -634,6 +754,12 @@ def detect_document(path):
634754 for symbol in word .symbols :
635755 print ('\t Symbol: {} (confidence: {})' .format (
636756 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 ))
637763 # [END vision_python_migration_document_text_detection]
638764# [END vision_fulltext_detection]
639765
@@ -667,6 +793,12 @@ def detect_document_uri(uri):
667793 for symbol in word .symbols :
668794 print ('\t Symbol: {} (confidence: {})' .format (
669795 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 ))
670802# [END vision_fulltext_detection_gcs]
671803
672804
0 commit comments