Skip to content

Commit a2fc2fb

Browse files
committed
BUG: Add exception for invalid keys that cannot be processed at runtime.
1 parent de6e33b commit a2fc2fb

File tree

1 file changed

+9
-3
lines changed
  • src/IO/GDCM/ReadAndPrintDICOMTags

1 file changed

+9
-3
lines changed

src/IO/GDCM/ReadAndPrintDICOMTags/Code.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,18 @@
6363
# GetMetaDataDictionary() method.
6464
metadata = dicomIO.GetMetaDataDictionary()
6565

66-
# Print the key value pairsa from the metadadictionary
66+
# Print the key value pairs from the metadadictionary
6767
tagkeys = metadata.GetKeys()
68+
6869
for tagkey in tagkeys:
6970
# Note the [] operator for the key
70-
tagvalue = metadata[tagkey]
71-
print(tagkey + '=' + str(tagvalue))
71+
try:
72+
tagvalue = metadata[tagkey]
73+
print(tagkey + '=' + str(tagvalue))
74+
except RuntimeError:
75+
#Cannot pass specialized values into metadata dictionary.
76+
print("Cannot pass specialized value" + tagkey + "into metadadictionary")
77+
7278

7379
# Illustrating use of getting a label given a tag here
7480
entryID = "0010|0010"

0 commit comments

Comments
 (0)