Issue 123 in pydicom: Descriptive error messages for invalid tags in the dataset

11 views
Skip to first unread message

pyd...@googlecode.com

unread,
Mar 29, 2013, 3:24:18 PM3/29/13
to pydic...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium Difficulty-Medium

New issue 123 by videa...@gmail.com: Descriptive error messages for invalid
tags in the dataset
http://code.google.com/p/pydicom/issues/detail?id=123

Pydicom correctly throws errors when a tag is of invalid type/value,
however it is nearly impossible to determine *which* tag is responsible for
the offending error message.

To reproduce
1. Load/create a dicom dataset
2. Write an incorrect type or value to a dicom tag, say an int where you
meant to write a string
3. Save the file (error with an unhelpful traceback)

Similarly:
1. Load a dataset with an invalid tag (anything that tickles DateElem.value
will do)
2. Call Dataset.walk (error with an unhelpful traceback)

What is the expected output? What do you see instead?
Pydicom correctly throws an exception when you make that call, but the high
level methods (walk, save_as, etc) boot you out at the top of the stack, so
it's difficult to see where the offender is (in my files it's usually deep
in a nested sequence... eww).

It would be nice if the traceback was annotated with the failed tag number
as the value is passed up the stack. I wrote an 8-line patch to fix that
(attached), although I'm sure there's a better way.

What version of the product are you using?

Pydicom 0.9.7, 0.9.8, trunk

Attached:

- ex_fail.py - Toy example that reproduces the problem
- tag_in_exception.patch - 8 line context manager to solve the problem in
Dataset.walk/Dataset.save_as/Dataset.__str__. I'm sure it could help
elsewhere too.


Attachments:
ex_fail.py 811 bytes
tag_in_exception.patch 3.7 KB

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

pyd...@googlecode.com

unread,
Apr 2, 2013, 9:44:12 PM4/2/13
to pydic...@googlegroups.com
Updates:
Status: Accepted
Owner: darcy...@gmail.com

Comment #1 on issue 123 by darcy...@gmail.com: Descriptive error messages
Yes, this is a good point -- pydicom should be more helpful in localizing a
bad value. I'll have a look at your patch.

pyd...@googlecode.com

unread,
Nov 22, 2014, 12:10:33 PM11/22/14
to pydic...@googlegroups.com
Updates:
Status: Fixed

Comment #2 on issue 123 by Sue...@gmail.com: Descriptive error messages for
invalid tags in the dataset
https://code.google.com/p/pydicom/issues/detail?id=123

This issue was closed by revision 03d4ee111dfa.
Reply all
Reply to author
Forward
0 new messages