Skip to content

Commit 7ed1998

Browse files
committed
ENH: better exception reporting in test
1 parent bc7cb5d commit 7ed1998

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

test/itkMontageTest.cxx

+26-10
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,33 @@ itkMontageTest(int argc, char * argv[])
149149
inputPath += '/';
150150
}
151151

152-
unsigned dim;
153-
itk::TileConfiguration<2>::TryParse(inputPath + "TileConfiguration.txt", dim);
152+
try
153+
{
154+
unsigned dim;
155+
itk::TileConfiguration<2>::TryParse(inputPath + "TileConfiguration.txt", dim);
154156

155-
switch (dim)
157+
switch (dim)
158+
{
159+
case 2:
160+
return itkMontageTestHelper<2>(argc, argv, inputPath);
161+
case 3:
162+
return itkMontageTestHelper<3>(argc, argv, inputPath);
163+
default:
164+
std::cerr << "Only dimensions 2 and 3 are supported. You are attempting to montage dimension " << dim;
165+
return EXIT_FAILURE;
166+
}
167+
}
168+
catch (itk::ExceptionObject & exc)
169+
{
170+
std::cerr << exc;
171+
}
172+
catch (std::runtime_error & exc)
173+
{
174+
std::cerr << exc.what();
175+
}
176+
catch (...)
156177
{
157-
case 2:
158-
return itkMontageTestHelper<2>(argc, argv, inputPath);
159-
case 3:
160-
return itkMontageTestHelper<3>(argc, argv, inputPath);
161-
default:
162-
std::cerr << "Only dimensions 2 and 3 are supported. You are attempting to montage dimension " << dim;
163-
return EXIT_FAILURE;
178+
std::cerr << "Unknown error has occurred" << std::endl;
164179
}
180+
return EXIT_FAILURE;
165181
}

0 commit comments

Comments
 (0)