mirror of https://github.com/ecmwf/eccodes.git
changed exception handling in python example
This commit is contained in:
parent
7d6c1a7072
commit
cc35c36b78
|
@ -59,8 +59,11 @@ def example():
|
||||||
|
|
||||||
# print the values for the selected keys from the message
|
# print the values for the selected keys from the message
|
||||||
for key in keys:
|
for key in keys:
|
||||||
if not codes_is_defined(gid,key): raise Exception("Key: " + key + " was not defined")
|
try:
|
||||||
print ' %s: %s' % (key,codes_get(gid,key))
|
print ' %s: %s' % (key,codes_get(gid,key))
|
||||||
|
except CodesInternalError,err:
|
||||||
|
print 'Error with key="%s" : %s' % (key,err.msg)
|
||||||
|
print err
|
||||||
|
|
||||||
cnt+=1
|
cnt+=1
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue