From cc35c36b7802a27239781808346d707da4706b50 Mon Sep 17 00:00:00 2001 From: Enrico Fucile Date: Mon, 23 Mar 2015 08:45:18 +0000 Subject: [PATCH] changed exception handling in python example --- examples/python/bufr_read_synop.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/python/bufr_read_synop.py b/examples/python/bufr_read_synop.py index e10dff3f1..f084e13fe 100644 --- a/examples/python/bufr_read_synop.py +++ b/examples/python/bufr_read_synop.py @@ -59,8 +59,11 @@ def example(): # print the values for the selected keys from the message for key in keys: - if not codes_is_defined(gid,key): raise Exception("Key: " + key + " was not defined") - print ' %s: %s' % (key,codes_get(gid,key)) + try: + print ' %s: %s' % (key,codes_get(gid,key)) + except CodesInternalError,err: + print 'Error with key="%s" : %s' % (key,err.msg) + print err cnt+=1