From 5fc768ca866b12e269541393e3bbe99322d26a1a Mon Sep 17 00:00:00 2001 From: tbaudier Date: Mon, 15 Jan 2018 11:36:32 +0100 Subject: [PATCH] Exception when tag is not found --- tools/clitkImageConvertGenericFilter.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/clitkImageConvertGenericFilter.cxx b/tools/clitkImageConvertGenericFilter.cxx index 1e95a7b..51a43a0 100644 --- a/tools/clitkImageConvertGenericFilter.cxx +++ b/tools/clitkImageConvertGenericFilter.cxx @@ -148,6 +148,10 @@ void clitk::ImageConvertGenericFilter::UpdateWithInputImageType() // Read the attribute Image Position (Patient) gdcm::Tag DetectorInformationSequenceTag(0x0054,0x0022); const gdcm::DataElement & DIS = ds.GetDataElement(DetectorInformationSequenceTag); + if (!DIS.GetByteValue()) { + std::cout << "Error: could not find 0x0054,0x0022 tag. Abort." << std::endl; + exit(0); + } gdcm::SmartPointer sqf = DIS.GetValueAsSQ(); gdcm::Item & item = sqf->GetItem(1); gdcm::DataSet & ds_position = item.GetNestedDataSet(); -- 2.47.1